@@ -571,44 +571,37 @@ static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *po
571
571
char * host = NULL ;
572
572
573
573
#ifdef HAVE_IPV6
574
+ char * p ;
575
+
574
576
if (* (str ) == '[' && str_len > 1 ) {
575
577
/* 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 );
577
579
if (!p || * (p + 1 ) != ':' ) {
578
580
if (get_err ) {
579
581
* err = strpprintf (0 , "Failed to parse IPv6 address \"%s\"" , str );
580
582
}
581
583
return NULL ;
582
584
}
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 );
590
586
return estrndup (str + 1 , p - str - 1 );
591
587
}
592
588
#endif
593
-
594
589
if (str_len ) {
595
590
colon = memchr (str , ':' , str_len - 1 );
596
591
} else {
597
592
colon = NULL ;
598
593
}
599
-
600
594
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 );
605
600
}
601
+ return NULL ;
606
602
}
607
603
608
- if (get_err ) {
609
- * err = strpprintf (0 , "Failed to parse address \"%s\"" , str );
610
- }
611
- return NULL ;
604
+ return host ;
612
605
}
613
606
614
607
static inline char * parse_ip_address (php_stream_xport_param * xparam , int * portno )
0 commit comments