[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] prop224: Fix coverity warnings from #20657 merge.
commit 21e5146529e4040c7391f3696baa5e6b4370d06d
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date: Wed Aug 9 13:45:37 2017 +0300
prop224: Fix coverity warnings from #20657 merge.
- Fix various ssize_t/size_t confusions in the tests.
- Fix a weird memset argument:
"bad_memset: Argument -16 in memset loses precision in
memset(&desc_two->blinded_kp.pubkey.pubkey, -16, 32UL)."
- Fix check_after_deref instance in check_state_line_for_service_rev_counter():
"check_after_deref: Null-checking items suggests that it may be null,
but it has already been dereferenced on all paths leading to the
check."
---
src/or/hs_service.c | 7 +++----
src/test/test_hs_intropoint.c | 14 ++++++++------
src/test/test_hs_service.c | 4 ++--
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 5f3696454..cb3a49cb8 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -2111,10 +2111,9 @@ check_state_line_for_service_rev_counter(const char *state_line,
b64_key_str, rev_counter);
done:
- if (items) {
- SMARTLIST_FOREACH(items, char*, s, tor_free(s));
- smartlist_free(items);
- }
+ tor_assert(items);
+ SMARTLIST_FOREACH(items, char*, s, tor_free(s));
+ smartlist_free(items);
return rev_counter;
}
diff --git a/src/test/test_hs_intropoint.c b/src/test/test_hs_intropoint.c
index 09af10904..a5031c5ae 100644
--- a/src/test/test_hs_intropoint.c
+++ b/src/test/test_hs_intropoint.c
@@ -446,14 +446,15 @@ test_establish_intro_wrong_sig(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 last byte (signature)! :) */
cell_body[cell_len - 1]++;
/* Receive the cell. Should fail. */
setup_full_capture_of_logs(LOG_INFO);
- retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
+ retval = hs_intro_received_establish_intro(intro_circ, cell_body,
+ (size_t)cell_len);
expect_log_msg_containing("Failed to verify ESTABLISH_INTRO cell.");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
@@ -482,14 +483,15 @@ helper_establish_intro_v3(or_circuit_t *intro_circ)
/* 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);
cell_len = trn_cell_establish_intro_encode(cell_body, sizeof(cell_body),
cell);
tt_int_op(cell_len, OP_GT, 0);
/* Receive the cell */
- retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
+ retval = hs_intro_received_establish_intro(intro_circ, cell_body,
+ (size_t) cell_len);
tt_int_op(retval, ==, 0);
done:
@@ -521,11 +523,11 @@ helper_establish_intro_v2(or_circuit_t *intro_circ)
(char*)cell_body,
sizeof(cell_body), key1,
circ_nonce);
- tt_int_op(cell_len, >, 0);
+ tt_int_op(cell_len, OP_GT, 0);
/* Receive legacy establish_intro */
retval = hs_intro_received_establish_intro(intro_circ,
- cell_body, cell_len);
+ cell_body, (size_t) cell_len);
tt_int_op(retval, ==, 0);
done:
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index aea2c8fbf..60efca15f 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -1258,9 +1258,9 @@ test_revision_counter_state(void *arg)
/* Prepare both descriptors */
desc_one->desc->plaintext_data.revision_counter = 42;
desc_two->desc->plaintext_data.revision_counter = 240;
- memset(&desc_one->blinded_kp.pubkey.pubkey, '\x42',
+ memset(&desc_one->blinded_kp.pubkey.pubkey, 66,
sizeof(desc_one->blinded_kp.pubkey.pubkey));
- memset(&desc_two->blinded_kp.pubkey.pubkey, '\xf0',
+ memset(&desc_two->blinded_kp.pubkey.pubkey, 240,
sizeof(desc_one->blinded_kp.pubkey.pubkey));
/* Turn the descriptor rev counters into state lines */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits