aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-02-21 20:23:21 +0100
committerNick Mathewson <nickm@torproject.org>2018-03-28 07:39:03 -0400
commit6b6d003f43cbbf01b40cedb0cc12ada2e81461f9 (patch)
tree829218907a1870688faad805ede2eb890d82be73 /src/common/util.c
parentd891010fdd4562e29a5a468232cd7b30430d7570 (diff)
downloadtor-6b6d003f43cbbf01b40cedb0cc12ada2e81461f9.tar.gz
tor-6b6d003f43cbbf01b40cedb0cc12ada2e81461f9.zip
Don't explode on NULL or empty string
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 1402462fb0..53e117f24c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1081,8 +1081,13 @@ string_is_valid_dest(const char *string)
int retval;
size_t len = strlen(string);
- tor_assert(string);
- tor_assert(len > 0);
+ if (string == NULL)
+ return 0;
+
+ len = strlen(string);
+
+ if (len == 0)
+ return 0;
if (string[0] == '[' && string[len - 1] == ']')
string = tmp = tor_strndup(string + 1, len - 2);