diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-11 09:38:20 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-11 11:16:50 -0400 |
commit | 5595b212270215eaa020603cabbe2c7b3b34d624 (patch) | |
tree | 1ea7bd05f23d00a7f09c7b769fbd350ba36880f7 /src/test/fuzz/fuzz_diff_apply.c | |
parent | e5601f14ed4384e8de1030d21cc7442df48adabe (diff) | |
download | tor-5595b212270215eaa020603cabbe2c7b3b34d624.tar.gz tor-5595b212270215eaa020603cabbe2c7b3b34d624.zip |
Consdiff: use lengths on inputs so they don't need NUL at the end
This is part of #27244, so that we can safely mmap consensus
documents.
Diffstat (limited to 'src/test/fuzz/fuzz_diff_apply.c')
-rw-r--r-- | src/test/fuzz/fuzz_diff_apply.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/test/fuzz/fuzz_diff_apply.c b/src/test/fuzz/fuzz_diff_apply.c index 165d0e6126..9b25185225 100644 --- a/src/test/fuzz/fuzz_diff_apply.c +++ b/src/test/fuzz/fuzz_diff_apply.c @@ -10,9 +10,11 @@ #include "test/fuzz/fuzzing.h" static int -mock_consensus_compute_digest_(const char *c, consensus_digest_t *d) +mock_consensus_compute_digest_(const char *c, size_t len, + consensus_digest_t *d) { (void)c; + (void)len; memset(d->sha3_256, 3, sizeof(d->sha3_256)); return 0; } @@ -50,16 +52,13 @@ fuzz_main(const uint8_t *stdin_buf, size_t data_size) if (! separator) return 0; size_t c1_len = separator - stdin_buf; - char *c1 = tor_memdup_nulterm(stdin_buf, c1_len); + const char *c1 = (const char *)stdin_buf; size_t c2_len = data_size - c1_len - SEPLEN; - char *c2 = tor_memdup_nulterm(separator + SEPLEN, c2_len); + const char *c2 = (const char *)separator + SEPLEN; - char *c3 = consensus_diff_apply(c1, c2); + char *c3 = consensus_diff_apply(c1, c1_len, c2, c2_len); - tor_free(c1); - tor_free(c2); tor_free(c3); return 0; } - |