diff --git a/test/Makefile.inc b/test/Makefile.inc index 9f871f2e..2fa98b18 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -22,8 +22,8 @@ TESTSOURCES = ares-test-main.cc \ TESTHEADERS = ares-test.h \ dns-proto.h -FUZZSOURCES = ares-test-fuzz.cc \ - ares-fuzz.cc +FUZZSOURCES = ares-test-fuzz.c \ + ares-fuzz.c DUMPSOURCES = dns-proto.cc \ dns-dump.cc diff --git a/test/ares-fuzz.cc b/test/ares-fuzz.c similarity index 84% rename from test/ares-fuzz.cc rename to test/ares-fuzz.c index e87979bb..92761286 100644 --- a/test/ares-fuzz.cc +++ b/test/ares-fuzz.c @@ -10,7 +10,7 @@ #include #include -static const int kMaxAflInputSize = 1 << 20; +#define kMaxAflInputSize (1 << 20) static unsigned char afl_buffer[kMaxAflInputSize]; #ifdef __AFL_LOOP @@ -21,9 +21,8 @@ static unsigned char afl_buffer[kMaxAflInputSize]; #define KEEP_FUZZING(count) ((count) < 1) #endif -/* In ares-test-fuzz.cc: */ -extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, - unsigned long size); +/* In ares-test-fuzz.c: */ +int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size); static void ProcessFile(int fd) { ssize_t count = read(fd, afl_buffer, kMaxAflInputSize); @@ -44,7 +43,8 @@ int main(int argc, char *argv[]) { count++; } } else { - for (int ii = 1; ii < argc; ++ii) { + int ii; + for (ii = 1; ii < argc; ++ii) { int fd = open(argv[ii], O_RDONLY); if (fd < 0) { fprintf(stderr, "Failed to open '%s'\n", argv[ii]); diff --git a/test/ares-test-fuzz.cc b/test/ares-test-fuzz.c similarity index 97% rename from test/ares-test-fuzz.cc rename to test/ares-test-fuzz.c index 5da52f3e..528e76c6 100644 --- a/test/ares-test-fuzz.cc +++ b/test/ares-test-fuzz.c @@ -3,9 +3,6 @@ #include "ares.h" // Entrypoint for Clang's libfuzzer -#ifdef __cplusplus -extern "C" -#endif int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) { // Feed the data into each of the ares_parse_*_reply functions.