diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-03-07 11:35:50 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-03-16 14:38:29 -0400 |
commit | 5766eed38f3fbf150691bcae84d82a1c16dbeb48 (patch) | |
tree | 0320cd350f0bf963e747c0a69bed3048da58ca8b /src/or/consdiff.c | |
parent | ab1fd85c999fe53af9503850c2642bd860e5b250 (diff) | |
download | tor-5766eed38f3fbf150691bcae84d82a1c16dbeb48.tar.gz tor-5766eed38f3fbf150691bcae84d82a1c16dbeb48.zip |
Fixes when applying diffs: Allow 2-line diffs, fix bogus free
The 2-line diff changs is needed to make the unit tests actually
test the cases that they thought they were testing.
The bogus free was found while testing those cases
Diffstat (limited to 'src/or/consdiff.c')
-rw-r--r-- | src/or/consdiff.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/or/consdiff.c b/src/or/consdiff.c index ed20e3b12f..defa1cfba5 100644 --- a/src/or/consdiff.c +++ b/src/or/consdiff.c @@ -859,7 +859,7 @@ consdiff_get_digests(smartlist_t *diff, const char *format; char cons1_hash[DIGEST256_LEN], cons2_hash[DIGEST256_LEN]; char *cons1_hash_hex, *cons2_hash_hex; - if (smartlist_len(diff) < 3) { + if (smartlist_len(diff) < 2) { log_info(LD_CONSDIFF, "The provided consensus diff is too short."); goto error_cleanup; } @@ -986,8 +986,6 @@ consdiff_apply_diff(smartlist_t *cons1, smartlist_t *diff, } cons2_str = smartlist_join_strings(cons2, "\n", 1, NULL); - SMARTLIST_FOREACH(cons2, char *, cp, tor_free(cp)); - smartlist_free(cons2); common_digests_t cons2_digests; if (router_get_networkstatus_v3_hashes(cons2_str, @@ -1014,18 +1012,17 @@ consdiff_apply_diff(smartlist_t *cons1, smartlist_t *diff, goto error_cleanup; } - return cons2_str; + goto done; - error_cleanup: + error_cleanup: + tor_free(cons2_str); /* Sets it to NULL */ + done: if (cons2) { SMARTLIST_FOREACH(cons2, char *, cp, tor_free(cp)); smartlist_free(cons2); } - if (cons2_str) { - tor_free(cons2_str); - } - return NULL; + return cons2_str; } |