mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
Add microdesc format fuzzer.
This commit is contained in:
parent
3c74855934
commit
4afb155db2
7
src/test/fuzz/dict/microdesc
Normal file
7
src/test/fuzz/dict/microdesc
Normal file
@ -0,0 +1,7 @@
|
||||
"onion-key"
|
||||
"ntor-onion-key"
|
||||
"id"
|
||||
"a"
|
||||
"family"
|
||||
"p"
|
||||
"p6"
|
45
src/test/fuzz/fuzz_microdesc.c
Normal file
45
src/test/fuzz/fuzz_microdesc.c
Normal file
@ -0,0 +1,45 @@
|
||||
#define ROUTERPARSE_PRIVATE
|
||||
#include "or.h"
|
||||
#include "routerparse.h"
|
||||
#include "microdesc.h"
|
||||
#include "fuzzing.h"
|
||||
|
||||
static void
|
||||
mock_dump_desc__nodump(const char *desc, const char *type)
|
||||
{
|
||||
(void)desc;
|
||||
(void)type;
|
||||
}
|
||||
|
||||
int
|
||||
fuzz_init(void)
|
||||
{
|
||||
disable_signature_checking();
|
||||
MOCK(dump_desc, mock_dump_desc__nodump);
|
||||
ed25519_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fuzz_cleanup(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fuzz_main(const uint8_t *data, size_t sz)
|
||||
{
|
||||
const char *str = (const char*) data;
|
||||
smartlist_t *result = microdescs_parse_from_string((const char *)str,
|
||||
str+sz,
|
||||
0, SAVED_NOWHERE, NULL);
|
||||
if (result) {
|
||||
log_debug(LD_GENERAL, "Parsing okay: %d", smartlist_len(result));
|
||||
SMARTLIST_FOREACH(result, microdesc_t *, md, microdesc_free(md));
|
||||
smartlist_free(result);
|
||||
} else {
|
||||
log_debug(LD_GENERAL, "Parsing failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,12 +47,22 @@ src_test_fuzz_fuzz_extrainfo_CFLAGS = $(FUZZING_CFLAGS)
|
||||
src_test_fuzz_fuzz_extrainfo_LDFLAGS = $(FUZZING_LDFLAG)
|
||||
src_test_fuzz_fuzz_extrainfo_LDADD = $(FUZZING_LIBS)
|
||||
|
||||
src_test_fuzz_fuzz_microdesc_SOURCES = \
|
||||
src/test/fuzz/fuzzing_common.c \
|
||||
src/test/fuzz/fuzz_microdesc.c
|
||||
src_test_fuzz_fuzz_microdesc_CPPFLAGS = $(FUZZING_CPPFLAGS)
|
||||
src_test_fuzz_fuzz_microdesc_CFLAGS = $(FUZZING_CFLAGS)
|
||||
src_test_fuzz_fuzz_microdesc_LDFLAGS = $(FUZZING_LDFLAG)
|
||||
src_test_fuzz_fuzz_microdesc_LDADD = $(FUZZING_LIBS)
|
||||
|
||||
FUZZERS = \
|
||||
src/test/fuzz/fuzz-descriptor \
|
||||
src/test/fuzz/fuzz-extrainfo \
|
||||
src/test/fuzz/fuzz-http
|
||||
src/test/fuzz/fuzz-http \
|
||||
src/test/fuzz/fuzz-microdesc
|
||||
|
||||
noinst_PROGRAMS += $(FUZZERS)
|
||||
fuzzers: $(FUZZERS)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user