Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,17 @@ PHP_FUNCTION(ip2long)
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
RETURN_FALSE;
}
#ifdef _AIX
/*
AIX accepts IP strings with excedentary 0 (192.168.042.42 will be treated as
192.168.42.42), while Linux don't.
For consistency, we convert back the IP to a string and check if it is equal to
the original string. If not, the IP should be considered invalid.
*/
if (strcmp(addr, inet_ntoa(ip)) != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick question: is inet_ntop available on AIX ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, inet_ntop is available

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is preferable over inet_ntoa. I know it s easier, but it is also deprecated.

RETURN_FALSE;
}
#endif
RETURN_LONG(ntohl(ip.s_addr));
}
/* }}} */
Expand Down
Loading