diff options
author | Anatol Belski <ab@php.net> | 2017-04-27 02:49:12 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-04-27 02:49:12 +0200 |
commit | 09ef61e3ca33d8f91b188cd0ad2512987671962b (patch) | |
tree | 6d722b16b739a8a5bb25705d8a415ae9b2feae4a /main | |
parent | bf3e2dce7b54988d82f16ee3564c14f1b5cd936b (diff) | |
download | php-git-09ef61e3ca33d8f91b188cd0ad2512987671962b.tar.gz |
Revert "Detect invalid port in xp_socket parse ip address"
This reverts commit bab0b99f376dac9170ac81382a5ed526938d595a.
Diffstat (limited to 'main')
-rw-r--r-- | main/streams/xp_socket.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 3ff64787aa..701a993ccc 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -571,44 +571,37 @@ static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *po char *host = NULL; #ifdef HAVE_IPV6 + char *p; + if (*(str) == '[' && str_len > 1) { /* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */ - char *p = memchr(str + 1, ']', str_len - 2), *e = NULL; + p = memchr(str + 1, ']', str_len - 2); if (!p || *(p + 1) != ':') { if (get_err) { *err = strpprintf(0, "Failed to parse IPv6 address \"%s\"", str); } return NULL; } - *portno = strtol(p + 2, &e, 10); - if (e && *e) { - if (get_err) { - *err = strpprintf(0, "Failed to parse address \"%s\"", str); - } - return NULL; - } + *portno = atoi(p + 2); return estrndup(str + 1, p - str - 1); } #endif - if (str_len) { colon = memchr(str, ':', str_len - 1); } else { colon = NULL; } - if (colon) { - char *e = NULL; - *portno = strtol(colon + 1, &e, 10); - if (!e || !*e) { - return estrndup(str, colon - str); + *portno = atoi(colon + 1); + host = estrndup(str, colon - str); + } else { + if (get_err) { + *err = strpprintf(0, "Failed to parse address \"%s\"", str); } + return NULL; } - if (get_err) { - *err = strpprintf(0, "Failed to parse address \"%s\"", str); - } - return NULL; + return host; } static inline char *parse_ip_address(php_stream_xport_param *xparam, int *portno) |