From: Yu Watanabe Date: Sat, 2 Mar 2024 04:50:50 +0000 (+0900) Subject: fuzz-lldp-rx: fuzz lldp_rx_build_neighbors_json() X-Git-Tag: v256-rc1~668^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eca7a4886de3839f061a57f1a2b5e06bc05e4c34;p=thirdparty%2Fsystemd.git fuzz-lldp-rx: fuzz lldp_rx_build_neighbors_json() Addresses https://github.com/systemd/systemd/pull/31583#discussion_r1509882453. --- diff --git a/src/libsystemd-network/fuzz-lldp-rx.c b/src/libsystemd-network/fuzz-lldp-rx.c index 844957c069e..24146b709da 100644 --- a/src/libsystemd-network/fuzz-lldp-rx.c +++ b/src/libsystemd-network/fuzz-lldp-rx.c @@ -9,6 +9,7 @@ #include "fd-util.h" #include "fuzz.h" #include "lldp-network.h" +#include "lldp-rx-internal.h" static int test_fd[2] = EBADF_PAIR; @@ -22,6 +23,7 @@ int lldp_network_bind_raw_socket(int ifindex) { int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { _cleanup_(sd_event_unrefp) sd_event *e = NULL; _cleanup_(sd_lldp_rx_unrefp) sd_lldp_rx *lldp_rx = NULL; + _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (outside_size_range(size, 0, 2048)) return 0; @@ -37,6 +39,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { assert_se(write(test_fd[1], data, size) == (ssize_t) size); assert_se(sd_event_run(e, 0) >= 0); + assert_se(lldp_rx_build_neighbors_json(lldp_rx, &v) >= 0); + assert_se(sd_lldp_rx_stop(lldp_rx) >= 0); assert_se(sd_lldp_rx_detach_event(lldp_rx) >= 0); test_fd[1] = safe_close(test_fd[1]);