We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 90cb181 commit 93ab5e9Copy full SHA for 93ab5e9
ext/standard/basic_functions.c
@@ -598,6 +598,17 @@ PHP_FUNCTION(ip2long)
598
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
599
RETURN_FALSE;
600
}
601
+#ifdef _AIX
602
+ /*
603
+ AIX accepts IP strings with excedentary 0 (192.168.042.42 will be treated as
604
+ 192.168.42.42), while Linux don't.
605
+ For consistency, we convert back the IP to a string and check if it is equal to
606
+ the original string. If not, the IP should be considered invalid.
607
+ */
608
+ if (strcmp(addr, inet_ntoa(ip)) != 0) {
609
+ RETURN_FALSE;
610
+ }
611
+#endif
612
RETURN_LONG(ntohl(ip.s_addr));
613
614
/* }}} */
0 commit comments