summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/fuzz-lldp-rx.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/libsystemd-network/fuzz-lldp-rx.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libsystemd-network/fuzz-lldp-rx.c')
-rw-r--r--src/libsystemd-network/fuzz-lldp-rx.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsystemd-network/fuzz-lldp-rx.c b/src/libsystemd-network/fuzz-lldp-rx.c
index 844957c..dad1038 100644
--- a/src/libsystemd-network/fuzz-lldp-rx.c
+++ b/src/libsystemd-network/fuzz-lldp-rx.c
@@ -9,6 +9,8 @@
#include "fd-util.h"
#include "fuzz.h"
#include "lldp-network.h"
+#include "lldp-rx-internal.h"
+#include "memstream-util.h"
static int test_fd[2] = EBADF_PAIR;
@@ -22,6 +24,9 @@ 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;
+ _cleanup_(memstream_done) MemStream m = {};
+ FILE *f;
if (outside_size_range(size, 0, 2048))
return 0;
@@ -37,6 +42,10 @@ 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(f = memstream_init(&m));
+ (void) json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR, f, NULL);
+
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]);