diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-15 14:04:19 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-15 14:04:19 -0400 |
commit | 0bd220adcb82670893c85b1cc24d64e615855b4f (patch) | |
tree | 7bd5328f90290c8516afbb515531b3f612978f08 /src/test/test_util.c | |
parent | 1dc0d26b50929ad3969a6aa759ce71e0d089bb33 (diff) | |
download | tor-0bd220adcb82670893c85b1cc24d64e615855b4f.tar.gz tor-0bd220adcb82670893c85b1cc24d64e615855b4f.zip |
Don't pass invalid memory regions to digestmap_set/get in test_routerlist
Fixes bug in c887e20e6a5a2c17c65; bug in no released Tor version.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index d1950037e3..962cb0e862 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -3362,30 +3362,24 @@ test_util_di_ops(void) test_eq(neq1, !eq1); } - /* exhaustively white-box test tor_memeq - * against each possible (single-byte) bit difference - * some arithmetic bugs only appear with certain bit patterns */ { - uint8_t zz = 0; - uint8_t ii = 0; - int z; - for (i = 0; i < 256; i++) { - ii = (uint8_t)i; - test_eq(tor_memeq(&zz, &ii, 1), zz == ii); - } - - /* exhaustively white-box test tor_memcmp - * against each possible single-byte numeric difference - * some arithmetic bugs only appear with certain bit patterns */ - for (z = 0; z < 256; z++) { - for (i = 0; i < 256; i++) { - ii = (uint8_t)i; - zz = (uint8_t)z; - test_eq(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ, zz > ii ? GT : EQ); - test_eq(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ, ii < zz ? LT : EQ); + uint8_t zz = 0; + uint8_t ii = 0; + int z; + + /* exhaustively test tor_memeq and tor_memcmp + * against each possible single-byte numeric difference + * some arithmetic bugs only appear with certain bit patterns */ + for (z = 0; z < 256; z++) { + for (i = 0; i < 256; i++) { + ii = (uint8_t)i; + zz = (uint8_t)z; + test_eq(tor_memeq(&zz, &ii, 1), zz == ii); + test_eq(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ, zz > ii ? GT : EQ); + test_eq(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ, ii < zz ? LT : EQ); + } } } - } tt_int_op(1, ==, safe_mem_is_zero("", 0)); tt_int_op(1, ==, safe_mem_is_zero("", 1)); |