commit 0015d0084262ddc60098b15d6cdf30ea66d59a53 Author: Nick Mathewson nickm@torproject.org Date: Sat Dec 1 20:46:06 2018 -0500
Use tor_strdup() in place of malloc+strncpy+terminate. --- src/tools/tor-resolve.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/tools/tor-resolve.c b/src/tools/tor-resolve.c index ba83f3e3b..803ed26b3 100644 --- a/src/tools/tor-resolve.c +++ b/src/tools/tor-resolve.c @@ -512,14 +512,7 @@ do_resolve(const char *hostname, domainname_t *dn = socks5_server_reply_get_bind_addr_domainname(reply);
- size_t result_len = (size_t)domainname_get_len(dn); - - *result_hostname = tor_malloc(result_len+1); - - strncpy(*result_hostname, (char *)domainname_getstr_name(dn), - result_len); - - (*result_hostname)[result_len] = '\0'; + *result_hostname = tor_strdup(domainname_getstr_name(dn)); }
socks5_server_reply_free(reply);
tor-commits@lists.torproject.org