From 372db1bf31ffcfbfc889912a3b30897a2d905682 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 1 Jul 2020 17:58:38 -0400 Subject: [PATCH] zebra, ospfd, vrrpd: update fuzzin' shims some function sigs changed, zebra got some new message types and a refactor. Signed-off-by: Quentin Young --- ospfd/ospf_main.c | 2 +- vrrpd/vrrp_main.c | 2 +- zebra/main.c | 8 +++++--- zebra/zapi_msg.c | 4 ++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 03df0a9ad1..fecbd8cad0 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -187,7 +187,7 @@ static bool FuzzingInit(void) static struct ospf *FuzzingCreateOspf(void) { struct prefix p; - struct interface *ifp = if_create_ifindex(69, 0); + struct interface *ifp = if_create_ifindex(69, 0, NULL); ifp->mtu = 68; str2prefix("11.0.2.0/24", &p); diff --git a/vrrpd/vrrp_main.c b/vrrpd/vrrp_main.c index d608e80198..ad8a624500 100644 --- a/vrrpd/vrrp_main.c +++ b/vrrpd/vrrp_main.c @@ -157,7 +157,7 @@ static struct vrrp_vrouter *FuzzingCreateVr(void) struct interface *ifp; struct prefix p; - ifp = if_create_ifindex(69, 0); + ifp = if_create_ifindex(69, 0, NULL); ifp->mtu = 68; str2prefix("11.0.2.1/24", &p); connected_add_by_prefix(ifp, &p, NULL); diff --git a/zebra/main.c b/zebra/main.c index ce1c27912a..e9192aa6b1 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -323,6 +323,8 @@ static bool FuzzingInit(void) static struct zserv *FuzzingZc; #endif /* FUZZING_LIBFUZZER */ +static struct stream_fifo *fifo; + static bool FuzzingInitialized; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) @@ -330,6 +332,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) if (!FuzzingInitialized) { FuzzingInit(); FuzzingInitialized = true; + fifo = stream_fifo_new(); } /* @@ -351,10 +354,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) struct stream *s = stream_new(size + 1); stream_put(s, data, size); + stream_fifo_push(fifo, s); - zserv_handle_commands(zc, s); - - stream_free(s); + zserv_handle_commands(zc, fifo); done: zserv_close_client(zc); diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index d1cd92eb07..f205c9bedc 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -2792,7 +2792,9 @@ static void zread_get_label_chunk(struct zserv *client, struct stream *msg, STREAM_GETL(s, size); STREAM_GETL(s, base); +#ifndef FUZZING assert(proto == client->proto && instance == client->instance); +#endif /* call hook to get a chunk using wrapper */ lm_get_chunk_call(&lmc, client, keep, size, base, vrf_id); @@ -2817,7 +2819,9 @@ static void zread_release_label_chunk(struct zserv *client, struct stream *msg) STREAM_GETL(s, start); STREAM_GETL(s, end); +#ifndef FUZZING assert(proto == client->proto && instance == client->instance); +#endif /* call hook to release a chunk using wrapper */ lm_release_chunk_call(client, start, end); -- 2.39.5