Fix assertion failure related to openbsd strtol().

Fixes bug 22789; bugfix on 0.2.3.8-alpha.
This commit is contained in:
Nick Mathewson
2017-07-03 11:20:09 -04:00
parent d56f699399
commit bb3f74e66b
3 changed files with 21 additions and 2 deletions
+6 -2
View File
@@ -2045,8 +2045,12 @@ tor_inet_pton(int af, const char *src, void *dst)
char *next;
ssize_t len;
long r = strtol(src, &next, 16);
tor_assert(next != NULL);
tor_assert(next != src);
if (next == NULL || next == src) {
/* The 'next == src' error case can happen on versions of openbsd
* where treats "0xfoo" as an error, rather than as "0" followed by
* "xfoo". */
return 0;
}
len = *next == '\0' ? eow - src : next - src;
if (len > 4)