Browse Source

Merge branch 'tor-github/pr/1154'

George Kadianakis 4 years ago
parent
commit
19e19c1fa8

+ 3 - 0
changes/ticket31030

@@ -0,0 +1,3 @@
+  o Minor bugfixes (coverity, tests):
+    - Fix several coverity warnings from our unit tests. Fixes bug 31030;
+      bugfix on 0.2.4.1-alpha, 0.3.2.1-alpha, and 0.4.0.1-alpha.

+ 4 - 0
src/test/test_btrack.c

@@ -44,6 +44,8 @@ test_btrack_launch(void *arg)
 {
   orconn_state_msg_t conn;
   ocirc_chan_msg_t circ;
+  memset(&conn, 0, sizeof(conn));
+  memset(&circ, 0, sizeof(circ));
 
   (void)arg;
   conn.gid = 1;
@@ -93,6 +95,8 @@ test_btrack_delete(void *arg)
 {
   orconn_state_msg_t state;
   orconn_status_msg_t status;
+  memset(&state, 0, sizeof(state));
+  memset(&status, 0, sizeof(status));
 
   (void)arg;
   state.gid = 1;

+ 3 - 0
src/test/test_controller_events.c

@@ -429,6 +429,7 @@ static void
 test_cntev_orconn_state(void *arg)
 {
   orconn_state_msg_t conn;
+  memset(&conn, 0, sizeof(conn));
 
   (void)arg;
   MOCK(queue_control_event_string, mock_queue_control_event_string);
@@ -468,6 +469,7 @@ static void
 test_cntev_orconn_state_pt(void *arg)
 {
   orconn_state_msg_t conn;
+  memset(&conn, 0, sizeof(conn));
 
   (void)arg;
   MOCK(queue_control_event_string, mock_queue_control_event_string);
@@ -503,6 +505,7 @@ static void
 test_cntev_orconn_state_proxy(void *arg)
 {
   orconn_state_msg_t conn;
+  memset(&conn, 0, sizeof(conn));
 
   (void)arg;
   MOCK(queue_control_event_string, mock_queue_control_event_string);

+ 1 - 0
src/test/test_hs_common.c

@@ -502,6 +502,7 @@ test_desc_reupload_logic(void *arg)
                 pubkey_hex, strlen(pubkey_hex));
   hs_build_address(&pubkey, HS_VERSION_THREE, onion_addr);
   service = tor_malloc_zero(sizeof(hs_service_t));
+  tt_assert(service);
   memcpy(service->onion_address, onion_addr, sizeof(service->onion_address));
   ed25519_secret_key_generate(&service->keys.identity_sk, 0);
   ed25519_public_key_generate(&service->keys.identity_pk,

+ 1 - 0
src/test/test_hs_service.c

@@ -1265,6 +1265,7 @@ test_service_event(void *arg)
 
   /* Set a service for this circuit. */
   service = helper_create_service();
+  tt_assert(service);
   ed25519_pubkey_copy(&circ->hs_ident->identity_pk,
                       &service->keys.identity_pk);
 

+ 2 - 1
src/test/test_introduce.c

@@ -383,8 +383,10 @@ make_intro_from_plaintext(
 
   /* Output the cell */
   *cell_out = cell;
+  cell = NULL;
 
  done:
+  tor_free(cell);
   return cell_len;
 }
 
@@ -535,4 +537,3 @@ struct testcase_t introduce_tests[] = {
   INTRODUCE_LEGACY(late_parse_v3),
   END_OF_TESTCASES
 };
-