]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Replace incorrect use of snprintf in unit tests with tor_snprintf
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>
Sun, 31 Jan 2016 23:07:19 +0000 (10:07 +1100)
committerNick Mathewson <nickm@torproject.org>
Mon, 1 Feb 2016 14:50:43 +0000 (09:50 -0500)
This avoids a potential out of bounds write.

src/test/test_tortls.c

index cbbd7dd3f346346e667196889a6a8c1eb5ae7318..98f5facc1199991e1cb012e123d780f7149e3fa0 100644 (file)
@@ -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: