summaryrefslogtreecommitdiff
path: root/main/streams/xp_socket.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-04-27 11:13:00 +0200
committerAnatol Belski <ab@php.net>2017-04-27 11:13:00 +0200
commit2111de0dd7d226bbb121565d32effe55cd2d3677 (patch)
tree50e94d82518769f3239cc25eccebbed6c3a3be05 /main/streams/xp_socket.c
parent67b701a60740cf369e64391c481d4b89da339687 (diff)
parent392bcba58d76fb497c0d0fccca97ee809a237871 (diff)
downloadphp-git-2111de0dd7d226bbb121565d32effe55cd2d3677.tar.gz
Merge branch 'PHP-7.1'
* PHP-7.1: Revert "Detect invalid port in xp_socket parse ip address" Revert "Follow up patch regarding bug #74216, see bug #74429"
Diffstat (limited to 'main/streams/xp_socket.c')
-rw-r--r--main/streams/xp_socket.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 9beac34f39..8efc4cdbc3 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 && *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 || *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)