summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-27 10:59:48 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-27 10:59:48 -0400
commit49deb1e1b810e348bfa9fb27a0f0ef54f3694cc9 (patch)
tree73aafa22564f22b5f681dac8e3ef302a0f3e422f /src/test
parent199e61feb560e2368d1eec475dd828118754cf71 (diff)
downloadtor-49deb1e1b810e348bfa9fb27a0f0ef54f3694cc9.tar.gz
tor-49deb1e1b810e348bfa9fb27a0f0ef54f3694cc9.zip
Document and test nul-terminating behavior of tor_uncompress()
We added this as a safety feature, but there are a few places in the code that actually depend on it.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_util.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 1f37fc3ab5..dec1d526c8 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2262,6 +2262,7 @@ test_util_compress_impl(compress_method_t method)
tt_assert(buf3 != NULL);
tt_int_op(strlen(buf1) + 1, OP_EQ, len2);
tt_str_op(buf1, OP_EQ, buf3);
+ tt_int_op(buf3[len2], OP_EQ, 0);
/* Check whether we can uncompress concatenated, compressed strings. */
tor_free(buf3);
@@ -2273,6 +2274,7 @@ test_util_compress_impl(compress_method_t method)
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0",
(strlen(buf1)+1)*2);
+ tt_int_op(buf3[len2], OP_EQ, 0);
/* Check whether we can uncompress partial strings */
@@ -2296,6 +2298,8 @@ test_util_compress_impl(compress_method_t method)
tt_int_op(len2, OP_GT, 5);
tt_int_op(len2, OP_LE, len1);
tt_assert(fast_memeq(buf1, buf3, len2));
+ tt_int_op(buf3[len2], OP_EQ, 0);
+
/* when we demand a complete output, this must fail. */
tor_free(buf3);
tt_assert(tor_uncompress(&buf3, &len2, buf2, len1-16,