Use CC for fuzzer, not CXX

This commit is contained in:
cpq 2022-09-30 11:44:50 +01:00
parent 0beef1d770
commit 0b3f6d6aab
2 changed files with 7 additions and 4 deletions

View File

@ -75,10 +75,9 @@ musl: RUN = $(DOCKER) mdashnet/cc1
unamalgamated: $(HDRS) Makefile test/packed_fs.c
$(CC) src/*.c test/packed_fs.c test/unit_test.c $(CFLAGS) $(LDFLAGS) -g -o unit_test
fuzz: WARN += -Wno-deprecated -Wno-vla-extension
fuzz: ASAN = -fsanitize=fuzzer,signed-integer-overflow,address,undefined
fuzz: mongoose.c mongoose.h Makefile test/fuzz.c
$(CXX) test/fuzz.c $(OPTS) $(WARN) $(INCS) $(TFLAGS) $(ASAN) -o fuzzer
$(CC) test/fuzz.c $(OPTS) $(WARN) $(INCS) $(TFLAGS) $(ASAN) -o fuzzer
$(RUN) ./fuzzer
fuzz2: mongoose.c mongoose.h Makefile test/fuzz.c

View File

@ -88,12 +88,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
#if defined(MAIN)
int main(int argc, char *argv[]) {
int res = EXIT_FAILURE;
if (argc > 1) {
size_t len = 0;
char *buf = mg_file_read(&mg_fs_posix, argv[1], &len);
if (buf != NULL) LLVMFuzzerTestOneInput((uint8_t *) buf, len);
if (buf != NULL) {
LLVMFuzzerTestOneInput((uint8_t *) buf, len);
res = EXIT_SUCCESS;
}
free(buf);
}
return 0;
return res;
}
#endif