summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-10-11 12:53:56 +0000
committerAntony Dovgal <tony2001@php.net>2006-10-11 12:53:56 +0000
commit1cc0339d403c06321fd0ee057a4efb4b8ef92704 (patch)
treec2d7179909d35ca069c16b26bd4e6496759ebd6f /main
parent2f467baf946eae829ff874a1a1516837e5b6e623 (diff)
downloadphp-git-1cc0339d403c06321fd0ee057a4efb4b8ef92704.tar.gz
MFH: fix crash when parsing invalid hostnames/IPs
Diffstat (limited to 'main')
-rw-r--r--main/streams/xp_socket.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index fe6fa16b9f..af2a060cff 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -495,7 +495,7 @@ static inline char *parse_ip_address_ex(const char *str, int str_len, int *portn
#ifdef HAVE_IPV6
char *p;
- if (*(str) == '[') {
+ if (*(str) == '[' && str_len > 1) {
/* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */
p = memchr(str + 1, ']', str_len - 2);
if (!p || *(p + 1) != ':') {
@@ -508,8 +508,11 @@ static inline char *parse_ip_address_ex(const char *str, int str_len, int *portn
return estrndup(str + 1, p - str - 1);
}
#endif
-
- colon = memchr(str, ':', str_len - 1);
+ if (str_len) {
+ colon = memchr(str, ':', str_len - 1);
+ } else {
+ colon = NULL;
+ }
if (colon) {
*portno = atoi(colon + 1);
host = estrndup(str, colon - str);