]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/fuzzing: Allow load of fuzz inputs as files on the command line
authorAndrew Bartlett <abartlet@samba.org>
Thu, 12 Dec 2019 23:01:01 +0000 (12:01 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 18 Dec 2019 06:39:26 +0000 (06:39 +0000)
This is easier to put under gdb.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/fuzzing/afl-fuzz-main.c

index 730aa39ae49d2b20fcb19467e111890d5ca454cb..9f6775578678f4222d19b23b8bf8c2d22335ea21 100644 (file)
@@ -28,6 +28,20 @@ int main(int argc, char *argv[]) {
        size_t size = 0;
 #ifdef __AFL_LOOP
        while (__AFL_LOOP(1000))
+#else
+       int i;
+       for (i = 0; i < argc; i++) {
+               uint8_t *buf = (uint8_t *)file_load(argv[i],
+                                                   &size,
+                                                   0,
+                                                   NULL);
+               ret = LLVMFuzzerTestOneInput(buf, size);
+               TALLOC_FREE(buf);
+               if (ret != 0) {
+                       return ret;
+               }
+       }
+       if (i == 0)
 #endif
        {
                uint8_t *buf = (uint8_t *)fd_load(0, &size, 0, NULL);