]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz-lldp: avoid assertion failure on samples which dont fit in pipe
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 26 Feb 2019 12:12:53 +0000 (13:12 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 26 Feb 2019 12:13:02 +0000 (13:13 +0100)
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11603.

src/fuzz/fuzz-lldp.c
src/fuzz/fuzz-lldp.options [new file with mode: 0644]

index b9291d47837f53eda717576959aea3928190d1c2..7f252309cd51d66474f39eb199911ed1d270efc4 100644 (file)
@@ -23,6 +23,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
         _cleanup_(sd_lldp_unrefp) sd_lldp *lldp = NULL;
 
+        if (size > 2048)
+                return 0;
+
         assert_se(sd_event_new(&e) == 0);
         assert_se(sd_lldp_new(&lldp) >= 0);
         assert_se(sd_lldp_set_ifindex(lldp, 42) >= 0);
diff --git a/src/fuzz/fuzz-lldp.options b/src/fuzz/fuzz-lldp.options
new file mode 100644 (file)
index 0000000..60bd9b0
--- /dev/null
@@ -0,0 +1,2 @@
+[libfuzzer]
+max_len = 2048