diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-11 10:32:17 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-11 11:43:26 -0400 |
commit | abaca3fc8c6bc54408084e7514468fa2cd7b3edf (patch) | |
tree | 38ed08599f113c13a7262a90cda1b4a3eb4a3a7d /src/test/fuzz/fuzz_consensus.c | |
parent | e014b72b73b2a299068f1ca5b7a22f2bea2f58f8 (diff) | |
download | tor-abaca3fc8c6bc54408084e7514468fa2cd7b3edf.tar.gz tor-abaca3fc8c6bc54408084e7514468fa2cd7b3edf.zip |
Revise networkstatus parsing code to use lengths
This way the networkstatus can be parsed without being
NUL-terminated, so we can implement 27244 and mmap our consensus objects.
Diffstat (limited to 'src/test/fuzz/fuzz_consensus.c')
-rw-r--r-- | src/test/fuzz/fuzz_consensus.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/fuzz/fuzz_consensus.c b/src/test/fuzz/fuzz_consensus.c index b170fd33d8..5a04683a11 100644 --- a/src/test/fuzz/fuzz_consensus.c +++ b/src/test/fuzz/fuzz_consensus.c @@ -59,13 +59,13 @@ int fuzz_main(const uint8_t *data, size_t sz) { networkstatus_t *ns; - char *str = tor_memdup_nulterm(data, sz); const char *eos = NULL; networkstatus_type_t tp = NS_TYPE_CONSENSUS; if (tor_memstr(data, MIN(sz, 1024), "tus vote")) tp = NS_TYPE_VOTE; const char *what = (tp == NS_TYPE_CONSENSUS) ? "consensus" : "vote"; - ns = networkstatus_parse_vote_from_string(str, + ns = networkstatus_parse_vote_from_string((const char *)data, + sz, &eos, tp); if (ns) { @@ -74,6 +74,6 @@ fuzz_main(const uint8_t *data, size_t sz) } else { log_debug(LD_GENERAL, "Parsing as %s failed", what); } - tor_free(str); + return 0; } |