aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_tortls.c
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-02-01 10:07:19 +1100
committerNick Mathewson <nickm@torproject.org>2016-02-01 09:50:43 -0500
commite3da5ad6e3bcee7cb9b639296e186fbeda5a6d9c (patch)
tree4fb40079fe68388c8d0ac1236caa37f0e68cef3e /src/test/test_tortls.c
parentf7b2ae91e9e6c9d4c3d5c993cd146829d3f1f3d7 (diff)
downloadtor-e3da5ad6e3bcee7cb9b639296e186fbeda5a6d9c.tar.gz
tor-e3da5ad6e3bcee7cb9b639296e186fbeda5a6d9c.zip
Replace incorrect use of snprintf in unit tests with tor_snprintf
This avoids a potential out of bounds write.
Diffstat (limited to 'src/test/test_tortls.c')
-rw-r--r--src/test/test_tortls.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c
index cbbd7dd3f3..98f5facc11 100644
--- a/src/test/test_tortls.c
+++ b/src/test/test_tortls.c
@@ -1808,9 +1808,10 @@ test_tortls_debug_state_callback(void *ignored)
tor_tls_debug_state_callback(ssl, 32, 45);
- n = snprintf(buf, 1000, "SSL %p is now in state unknown"
+ n = tor_snprintf(buf, 1000, "SSL %p is now in state unknown"
" state [type=32,val=45].\n", ssl);
- buf[n]='\0';
+ /* tor's snprintf returns -1 on error */
+ tt_int_op(n, OP_NE, -1);
expect_log_msg(buf);
done: