test: make fuzzer driver code C not C++

pull/62/head
David Drysdale 9 years ago
parent 5a1ae0bc7a
commit edc76de17e
  1. 4
      test/Makefile.inc
  2. 10
      test/ares-fuzz.c
  3. 3
      test/ares-test-fuzz.c

@ -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

@ -10,7 +10,7 @@
#include <string.h>
#include <unistd.h>
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]);

@ -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.
Loading…
Cancel
Save