]>
git.proxmox.com Git - mirror_frr.git/blob - tests/lib/fuzz_zlog.c
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "zlog_5424.h"
33 static char buffer
[65536];
35 int main(int argc
, char **argv
)
39 int pair
[2] = {-1, -1};
41 if (read(0, &io
, sizeof(io
)) != sizeof(io
))
43 if (io
.fmt
> ZLOG_FMT_LAST
)
51 socketpair(AF_UNIX
, SOCK_STREAM
, 0, pair
);
55 socketpair(AF_UNIX
, SOCK_SEQPACKET
, 0, pair
);
59 socketpair(AF_UNIX
, SOCK_DGRAM
, 0, pair
);
76 while (read(pair
[1], buf
, sizeof(buf
)) > 0)
79 } else if (child
== -1) {
86 for (size_t i
= 0; i
< sizeof(buffer
); i
++)
87 buffer
[i
] = (i
| 0x20) & 0x7f;
89 zlog_aux_init("FUZZBALL: ", LOG_DEBUG
);
90 zlog_tls_buffer_init();
92 struct zlog_cfg_5424 cfg
[1] = {};
96 cfg
->facility
= LOG_DAEMON
;
97 cfg
->prio_min
= LOG_DEBUG
;
98 cfg
->kw_version
= true;
99 cfg
->kw_location
= true;
106 cfg
->dst
= ZLOG_5424_DST_FD
;
109 cmd_hostname_set("TEST");
110 cfg
->master
= thread_master_create("TEST");
112 zlog_5424_apply_dst(cfg
);
114 zlog_debug("test #1 %.*s", (int)io
.out1_debug
, buffer
);
115 zlog_debug("test #2 %.*s", (int)io
.out2_debug
, buffer
);
116 zlog_warn("test #1 %.*s", (int)io
.out3_warn
, buffer
);
118 zlog_tls_buffer_flush();
119 zlog_tls_buffer_fini();
121 /* AFL++ seems to do some weird stuff with its fuzzing target, make
122 * sure the fork() child is zapped here rather than creating hordes
127 kill(child
, SIGTERM
);