[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] In test_establish_intro_wrong_purpose, use tt_i64_op on ssize_t



commit 5b8956df3b3bc4593c0372703cfb07d75b4fc15e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Aug 28 10:11:49 2017 -0400

    In test_establish_intro_wrong_purpose, use tt_i64_op on ssize_t
    
    Since ssize_t is signed and might be 64 bits, we should use
    tt_i64_op to make sure it's positive.  Otherwise, if it is negative,
    and we use tt_u64_op, we'll be treating it as a uint64_t, and we
    won't detect negative values.
    
    This fixes CID 1416338 and 1416339.  Bug not in any released Tor.
---
 src/test/test_hs_intropoint.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/test/test_hs_intropoint.c b/src/test/test_hs_intropoint.c
index 2c8f78008..2cce8a370 100644
--- a/src/test/test_hs_intropoint.c
+++ b/src/test/test_hs_intropoint.c
@@ -48,10 +48,10 @@ new_establish_intro_cell(const char *circ_nonce,
   ip = service_intro_point_new(NULL, 0);
   tt_assert(ip);
   cell_len = hs_cell_build_establish_intro(circ_nonce, ip, buf);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
 
   cell_len = trn_cell_establish_intro_parse(&cell, buf, sizeof(buf));
-  tt_int_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
   tt_assert(cell);
   *cell_out = cell;
 
@@ -71,7 +71,7 @@ new_establish_intro_encoded_cell(const char *circ_nonce, uint8_t *cell_out)
   ip = service_intro_point_new(NULL, 0);
   tt_assert(ip);
   cell_len = hs_cell_build_establish_intro(circ_nonce, ip, cell_out);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
 
  done:
   service_intro_point_free(ip);
@@ -184,7 +184,7 @@ test_establish_intro_wrong_purpose(void *arg)
   /* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
      attempt to parse it. */
   cell_len = new_establish_intro_encoded_cell(circ_nonce, cell_body);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
 
   /* Receive the cell. Should fail. */
   setup_full_capture_of_logs(LOG_INFO);
@@ -250,7 +250,7 @@ test_establish_intro_wrong_keytype2(void *arg)
   /* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
    * attempt to parse it. */
   cell_len = new_establish_intro_encoded_cell(circ_nonce, cell_body);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
 
   /* Mutate the auth key type! :) */
   cell_body[0] = 42;
@@ -286,7 +286,7 @@ test_establish_intro_wrong_mac(void *arg)
   /* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
    * attempt to parse it. */
   cell_len = new_establish_intro_cell(circ_nonce, &cell);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
   tt_assert(cell);
 
   /* Mangle one byte of the MAC. */
@@ -307,7 +307,7 @@ test_establish_intro_wrong_mac(void *arg)
     /* Encode payload so we can sign it. */
     cell_len = trn_cell_establish_intro_encode(cell_body, sizeof(cell_body),
                                                cell);
-    tt_int_op(cell_len, OP_GT, 0);
+    tt_i64_op(cell_len, OP_GT, 0);
 
     retval = ed25519_sign_prefixed(&sig, cell_body,
                                    cell_len -
@@ -321,7 +321,7 @@ test_establish_intro_wrong_mac(void *arg)
     /* Re-encode with the new signature. */
     cell_len = trn_cell_establish_intro_encode(cell_body, sizeof(cell_body),
                                                cell);
-    tt_int_op(cell_len, OP_GT, 0);
+    tt_i64_op(cell_len, OP_GT, 0);
   }
 
   /* Receive the cell. Should fail because our MAC is wrong. */
@@ -358,7 +358,7 @@ test_establish_intro_wrong_auth_key_len(void *arg)
   /* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
    * attempt to parse it. */
   cell_len = new_establish_intro_cell(circ_nonce, &cell);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
   tt_assert(cell);
 
   /* Mangle the auth key length. */
@@ -403,7 +403,7 @@ test_establish_intro_wrong_sig_len(void *arg)
   /* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
    * attempt to parse it. */
   cell_len = new_establish_intro_cell(circ_nonce, &cell);
-  tt_u64_op(cell_len, OP_GT, 0);
+  tt_i64_op(cell_len, OP_GT, 0);
   tt_assert(cell);
 
   /* Mangle the signature length. */

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits