aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-11 10:09:12 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-11 11:16:50 -0400
commite014b72b73b2a299068f1ca5b7a22f2bea2f58f8 (patch)
tree1a488fb068a55ebaa7d1a8d29929a6dfa76608d8 /src/test/fuzz
parent5595b212270215eaa020603cabbe2c7b3b34d624 (diff)
downloadtor-e014b72b73b2a299068f1ca5b7a22f2bea2f58f8.tar.gz
tor-e014b72b73b2a299068f1ca5b7a22f2bea2f58f8.zip
Stop memcpy'ing uncompressed consensuses when making diffs
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/fuzz_diff.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/test/fuzz/fuzz_diff.c b/src/test/fuzz/fuzz_diff.c
index 8966856be2..64aecc8a64 100644
--- a/src/test/fuzz/fuzz_diff.c
+++ b/src/test/fuzz/fuzz_diff.c
@@ -48,18 +48,27 @@ fuzz_main(const uint8_t *stdin_buf, size_t data_size)
size_t c2_len = data_size - c1_len - SEPLEN;
const char *c2 = (const char *)separator + SEPLEN;
+ const char *cp = memchr(c1, 0, c1_len);
+ if (cp)
+ c1_len = cp - c1;
+
+ cp = memchr(c2, 0, c2_len);
+ if (cp)
+ c2_len = cp - c2;
+
char *c3 = consensus_diff_generate(c1, c1_len, c2, c2_len);
if (c3) {
char *c4 = consensus_diff_apply(c1, c1_len, c3, strlen(c3));
tor_assert(c4);
- if (strcmp(c2, c4)) {
- printf("%s\n", escaped(c1));
- printf("%s\n", escaped(c2));
+ int equal = (c2_len == strlen(c4)) && fast_memeq(c2, c4, c2_len);
+ if (! equal) {
+ //printf("%s\n", escaped(c1));
+ //printf("%s\n", escaped(c2));
printf("%s\n", escaped(c3));
printf("%s\n", escaped(c4));
}
- tor_assert(! strcmp(c2, c4));
+ tor_assert(equal);
tor_free(c3);
tor_free(c4);
}