From 1a94a6f1b346af407d41001c7a83282dd6b15e25 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 10 Oct 2021 10:34:27 +1100 Subject: [PATCH] Choose fuzzer's static-ness on program vs library Some sanitizers don't work well with static functions. Updates https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39767 --- fuzz/c/std/bmp_fuzzer.c | 2 ++ fuzz/c/std/cbor_fuzzer.c | 2 ++ fuzz/c/std/gif_fuzzer.c | 2 ++ fuzz/c/std/json_fuzzer.cc | 2 ++ fuzz/c/std/pixel_swizzler_fuzzer.c | 2 ++ fuzz/c/std/png_fuzzer.c | 2 ++ fuzz/c/std/zlib_fuzzer.c | 2 ++ 7 files changed, 14 insertions(+) diff --git a/fuzz/c/std/bmp_fuzzer.c b/fuzz/c/std/bmp_fuzzer.c index a0789399..d9a0eca3 100644 --- a/fuzz/c/std/bmp_fuzzer.c +++ b/fuzz/c/std/bmp_fuzzer.c @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the diff --git a/fuzz/c/std/cbor_fuzzer.c b/fuzz/c/std/cbor_fuzzer.c index e2150444..2fcd01b8 100644 --- a/fuzz/c/std/cbor_fuzzer.c +++ b/fuzz/c/std/cbor_fuzzer.c @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the diff --git a/fuzz/c/std/gif_fuzzer.c b/fuzz/c/std/gif_fuzzer.c index 4eb19f9d..b3d01464 100644 --- a/fuzz/c/std/gif_fuzzer.c +++ b/fuzz/c/std/gif_fuzzer.c @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the diff --git a/fuzz/c/std/json_fuzzer.cc b/fuzz/c/std/json_fuzzer.cc index 54a97add..91f3c8a6 100644 --- a/fuzz/c/std/json_fuzzer.cc +++ b/fuzz/c/std/json_fuzzer.cc @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the diff --git a/fuzz/c/std/pixel_swizzler_fuzzer.c b/fuzz/c/std/pixel_swizzler_fuzzer.c index c5ef45a6..e826e23f 100644 --- a/fuzz/c/std/pixel_swizzler_fuzzer.c +++ b/fuzz/c/std/pixel_swizzler_fuzzer.c @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the diff --git a/fuzz/c/std/png_fuzzer.c b/fuzz/c/std/png_fuzzer.c index 7e73d894..2b3a6402 100644 --- a/fuzz/c/std/png_fuzzer.c +++ b/fuzz/c/std/png_fuzzer.c @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the diff --git a/fuzz/c/std/zlib_fuzzer.c b/fuzz/c/std/zlib_fuzzer.c index 2ddcf00a..dab9bfd6 100644 --- a/fuzz/c/std/zlib_fuzzer.c +++ b/fuzz/c/std/zlib_fuzzer.c @@ -42,6 +42,7 @@ It should print "PASS", amongst other information, and exit(0). // compiling it. #define WUFFS_IMPLEMENTATION +#if defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when // combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs' // functions have static storage. @@ -51,6 +52,7 @@ It should print "PASS", amongst other information, and exit(0). // "ALLOW STATIC IMPLEMENTATION" section of // https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt #define WUFFS_CONFIG__STATIC_FUNCTIONS +#endif // defined(WUFFS_CONFIG__FUZZLIB_MAIN) // Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of // release/c/etc.c choose which parts of Wuffs to build. That file contains the