]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Detect errors in fuzzer initialization
authorPetr Špaček <pspacek@isc.org>
Tue, 27 Sep 2022 08:32:34 +0000 (10:32 +0200)
committerPetr Špaček <pspacek@isc.org>
Tue, 27 Sep 2022 11:23:16 +0000 (13:23 +0200)
Incomplete initialization typically causes mysterious failures later on,
so let's err out early.

(cherry picked from commit d102c59b96f8859d1f354380d8cf3d7932553956)

fuzz/main.c

index ddddfe8fe36d67c6ec30ee29479102cba71373c0..4bfc66e1c66c112d4c8c61f604be4ada9ea68a33 100644 (file)
@@ -94,10 +94,15 @@ test_all_from(const char *dirname) {
 
 int
 main(int argc, char **argv) {
+       int ret;
        char corpusdir[PATH_MAX];
        const char *target = strrchr(argv[0], '/');
 
-       (void)LLVMFuzzerInitialize(&argc, &argv);
+       ret = LLVMFuzzerInitialize(&argc, &argv);
+       if (ret != 0) {
+               fprintf(stderr, "LLVMFuzzerInitialize failure: %d\n", ret);
+               return 1;
+       }
 
        if (argv[1] != NULL && strcmp(argv[1], "-d") == 0) {
                debug = true;
@@ -134,7 +139,11 @@ main(int argc, char **argv) {
        int ret;
        unsigned char buf[64 * 1024];
 
-       (void)LLVMFuzzerInitialize(&argc, &argv);
+       LLVMFuzzerInitialize(&argc, &argv);
+       if (ret != 0) {
+               fprintf(stderr, "LLVMFuzzerInitialize failure: %d\n", ret);
+               return 1;
+       }
 
 #ifdef __AFL_LOOP
        while (__AFL_LOOP(10000)) { /* only works with afl-clang-fast */