Skip to content

Commit ee9650c

Browse files
weltlingkrakjoe
authored andcommitted
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Revert "Detect invalid port in xp_socket parse ip address" Revert "Follow up patch regarding bug #74216, see bug #74429"
1 parent 4951d16 commit ee9650c

File tree

2 files changed

+11
-55
lines changed

2 files changed

+11
-55
lines changed

ext/standard/tests/streams/parseip-001.phpt

Lines changed: 0 additions & 37 deletions
This file was deleted.

main/streams/xp_socket.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -571,44 +571,37 @@ static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *po
571571
char *host = NULL;
572572

573573
#ifdef HAVE_IPV6
574+
char *p;
575+
574576
if (*(str) == '[' && str_len > 1) {
575577
/* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */
576-
char *p = memchr(str + 1, ']', str_len - 2), *e = NULL;
578+
p = memchr(str + 1, ']', str_len - 2);
577579
if (!p || *(p + 1) != ':') {
578580
if (get_err) {
579581
*err = strpprintf(0, "Failed to parse IPv6 address \"%s\"", str);
580582
}
581583
return NULL;
582584
}
583-
*portno = strtol(p + 2, &e, 10);
584-
if (e && *e && *e != '/') {
585-
if (get_err) {
586-
*err = strpprintf(0, "Failed to parse address \"%s\"", str);
587-
}
588-
return NULL;
589-
}
585+
*portno = atoi(p + 2);
590586
return estrndup(str + 1, p - str - 1);
591587
}
592588
#endif
593-
594589
if (str_len) {
595590
colon = memchr(str, ':', str_len - 1);
596591
} else {
597592
colon = NULL;
598593
}
599-
600594
if (colon) {
601-
char *e = NULL;
602-
*portno = strtol(colon + 1, &e, 10);
603-
if (!e || !*e || *e == '/') {
604-
return estrndup(str, colon - str);
595+
*portno = atoi(colon + 1);
596+
host = estrndup(str, colon - str);
597+
} else {
598+
if (get_err) {
599+
*err = strpprintf(0, "Failed to parse address \"%s\"", str);
605600
}
601+
return NULL;
606602
}
607603

608-
if (get_err) {
609-
*err = strpprintf(0, "Failed to parse address \"%s\"", str);
610-
}
611-
return NULL;
604+
return host;
612605
}
613606

614607
static inline char *parse_ip_address(php_stream_xport_param *xparam, int *portno)

0 commit comments

Comments
 (0)