mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-23 22:47:12 +01:00
Refactor poison_dir allocation and free in test_single_onion_poisoning
This pattern is much less error-prone when future changes are made.
This commit is contained in:
parent
907cd8a0cf
commit
c100c5c69b
1 changed files with 4 additions and 2 deletions
|
@ -541,6 +541,7 @@ test_single_onion_poisoning(void *arg)
|
||||||
rend_service_t *service_2 = tor_malloc_zero(sizeof(rend_service_t));
|
rend_service_t *service_2 = tor_malloc_zero(sizeof(rend_service_t));
|
||||||
char *dir2 = tor_strdup(get_fname_rnd("test_hs_dir2"));
|
char *dir2 = tor_strdup(get_fname_rnd("test_hs_dir2"));
|
||||||
smartlist_t *services = smartlist_new();
|
smartlist_t *services = smartlist_new();
|
||||||
|
char *poison_path = NULL;
|
||||||
|
|
||||||
/* No services, no service to verify, no problem! */
|
/* No services, no service to verify, no problem! */
|
||||||
mock_options->HiddenServiceSingleHopMode = 0;
|
mock_options->HiddenServiceSingleHopMode = 0;
|
||||||
|
@ -706,9 +707,9 @@ test_single_onion_poisoning(void *arg)
|
||||||
|
|
||||||
/* Now remove the poisoning from the first service, and we have the opposite
|
/* Now remove the poisoning from the first service, and we have the opposite
|
||||||
* problem. */
|
* problem. */
|
||||||
char *poison_path = rend_service_sos_poison_path(service_1);
|
poison_path = rend_service_sos_poison_path(service_1);
|
||||||
|
tt_assert(poison_path);
|
||||||
ret = unlink(poison_path);
|
ret = unlink(poison_path);
|
||||||
tor_free(poison_path);
|
|
||||||
tt_assert(ret == 0);
|
tt_assert(ret == 0);
|
||||||
|
|
||||||
/* Unpoisoned service directories with previous keys are ok, as are empty
|
/* Unpoisoned service directories with previous keys are ok, as are empty
|
||||||
|
@ -765,6 +766,7 @@ test_single_onion_poisoning(void *arg)
|
||||||
tt_assert(ret == 0);
|
tt_assert(ret == 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
tor_free(poison_path);
|
||||||
tor_free(dir1);
|
tor_free(dir1);
|
||||||
tor_free(dir2);
|
tor_free(dir2);
|
||||||
/* The test harness deletes the directories at exit */
|
/* The test harness deletes the directories at exit */
|
||||||
|
|
Loading…
Add table
Reference in a new issue