summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2015-02-17 18:53:33 +0000
committerYawning Angel <yawning@schwanenlied.me>2015-02-17 18:53:33 +0000
commitcbd26157c52e27af16efcb474861eb4126085283 (patch)
treebd6705b51cf4dcda50715f734d3565a9806d3d50
parentd038430a1409fbb28ea4d0b62654fc3cc7bb1f7a (diff)
downloadtor-cbd26157c52e27af16efcb474861eb4126085283.tar.gz
tor-cbd26157c52e27af16efcb474861eb4126085283.zip
Remove tor_strclear(), and replace previous calls with memwipe().
-rw-r--r--src/common/util.c10
-rw-r--r--src/common/util.h1
-rw-r--r--src/or/rendservice.c4
-rw-r--r--src/test/test_util.c21
4 files changed, 2 insertions, 34 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 442d57a2cf..2c3a1a1019 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -771,16 +771,6 @@ fast_memcmpstart(const void *mem, size_t memlen,
return fast_memcmp(mem, prefix, plen);
}
-/** Given a nul-terminated string s, set every character before the nul
- * to zero. */
-void
-tor_strclear(char *s)
-{
- while (*s) {
- *s++ = '\0';
- }
-}
-
/** Return a pointer to the first char of s that is not whitespace and
* not a comment, or to the terminating NUL if no such character exists.
*/
diff --git a/src/common/util.h b/src/common/util.h
index ea774bd9bd..783c2a13db 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -209,7 +209,6 @@ int strcasecmpstart(const char *s1, const char *s2) ATTR_NONNULL((1,2));
int strcmpend(const char *s1, const char *s2) ATTR_NONNULL((1,2));
int strcasecmpend(const char *s1, const char *s2) ATTR_NONNULL((1,2));
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
-void tor_strclear(char *s);
void tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2));
long tor_parse_long(const char *s, int base, long min,
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 6c934c8c12..036869650c 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -173,7 +173,7 @@ rend_authorized_client_free(rend_authorized_client_t *client)
return;
if (client->client_key)
crypto_pk_free(client->client_key);
- tor_strclear(client->client_name);
+ memwipe(client->client_name, 0, strlen(client->client_name));
tor_free(client->client_name);
memwipe(client->descriptor_cookie, 0, sizeof(client->descriptor_cookie));
tor_free(client);
@@ -1052,7 +1052,7 @@ rend_service_load_auth_keys(rend_service_t *s, const char *hfname)
abort_writing_to_file(open_hfile);
done:
if (client_keys_str) {
- tor_strclear(client_keys_str);
+ memwipe(client_keys_str, 0, strlen(client_keys_str));
tor_free(client_keys_str);
}
strmap_free(parsed_clients, rend_authorized_client_strmap_item_free);
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 9939bf4e3e..41dd9174d6 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -4111,26 +4111,6 @@ test_util_laplace(void *arg)
;
}
-static void
-test_util_strclear(void *arg)
-{
- static const char *vals[] = { "", "a", "abcdef", "abcdefgh", NULL };
- int i;
- char *v = NULL;
- (void)arg;
-
- for (i = 0; vals[i]; ++i) {
- size_t n;
- v = tor_strdup(vals[i]);
- n = strlen(v);
- tor_strclear(v);
- tt_assert(tor_mem_is_zero(v, n+1));
- tor_free(v);
- }
- done:
- tor_free(v);
-}
-
#define UTIL_LEGACY(name) \
{ #name, test_util_ ## name , 0, NULL, NULL }
@@ -4351,7 +4331,6 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY(di_ops),
UTIL_TEST(round_to_next_multiple_of, 0),
UTIL_TEST(laplace, 0),
- UTIL_TEST(strclear, 0),
UTIL_TEST(find_str_at_start_of_line, 0),
UTIL_TEST(string_is_C_identifier, 0),
UTIL_TEST(asprintf, 0),