mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Call strlen() once
This commit is contained in:
parent
b0ba4aa7e9
commit
5986589b48
@ -1081,12 +1081,13 @@ string_is_valid_dest(const char *string)
|
|||||||
{
|
{
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
int retval;
|
int retval;
|
||||||
|
size_t len = strlen(string);
|
||||||
|
|
||||||
tor_assert(string);
|
tor_assert(string);
|
||||||
tor_assert(strlen(string) > 0);
|
tor_assert(len > 0);
|
||||||
|
|
||||||
if (string[0] == '[' && string[strlen(string) - 1] == ']')
|
if (string[0] == '[' && string[len - 1] == ']')
|
||||||
string = tmp = tor_strndup(string + 1, strlen(string) - 2);
|
string = tmp = tor_strndup(string + 1, len - 2);
|
||||||
|
|
||||||
retval = string_is_valid_ipv4_address(string) ||
|
retval = string_is_valid_ipv4_address(string) ||
|
||||||
string_is_valid_ipv6_address(string) ||
|
string_is_valid_ipv6_address(string) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user