Explorar el Código

Coverity: fix test issues with always-present 'service' var.

Coverity is worried that we check "service" at the end of these test
functions, since it doesn't see any way to reach the cleanup code
without having first dereferenced the variable.

Removing the check would be unwise in this case: instead we add a
tt_assert check before using "service" so that coverity thinks that
the check is doing something useful.

Bugfix on 0.3.2.1-alpha.
Nick Mathewson hace 6 años
padre
commit
5fa2b32200
Se han modificado 2 ficheros con 2 adiciones y 0 borrados
  1. 1 0
      src/test/test_hs_common.c
  2. 1 0
      src/test/test_hs_service.c

+ 1 - 0
src/test/test_hs_common.c

@@ -502,6 +502,7 @@ test_desc_reupload_logic(void *arg)
                 pubkey_hex, strlen(pubkey_hex));
                 pubkey_hex, strlen(pubkey_hex));
   hs_build_address(&pubkey, HS_VERSION_THREE, onion_addr);
   hs_build_address(&pubkey, HS_VERSION_THREE, onion_addr);
   service = tor_malloc_zero(sizeof(hs_service_t));
   service = tor_malloc_zero(sizeof(hs_service_t));
+  tt_assert(service);
   memcpy(service->onion_address, onion_addr, sizeof(service->onion_address));
   memcpy(service->onion_address, onion_addr, sizeof(service->onion_address));
   ed25519_secret_key_generate(&service->keys.identity_sk, 0);
   ed25519_secret_key_generate(&service->keys.identity_sk, 0);
   ed25519_public_key_generate(&service->keys.identity_pk,
   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. */
   /* Set a service for this circuit. */
   service = helper_create_service();
   service = helper_create_service();
+  tt_assert(service);
   ed25519_pubkey_copy(&circ->hs_ident->identity_pk,
   ed25519_pubkey_copy(&circ->hs_ident->identity_pk,
                       &service->keys.identity_pk);
                       &service->keys.identity_pk);