Skip to content
Closed
Changes from 2 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
12 changes: 12 additions & 0 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,18 @@ PHP_FUNCTION(ip2long)
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
RETURN_FALSE;
}
#ifdef _AIX
/*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the diff show indentation misalignment (see the line above).

AIX accepts IP strings with excedentary 0 (192.168.042.42 will be treated as
192.168.42.42), while Linux don't.
Copy link
Copy Markdown
Contributor

@mvorisek mvorisek Feb 27, 2026

Choose a reason for hiding this comment

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

If such functionality is expected, it should be tested.

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.
*/
char str[INET_ADDRSTRLEN];
if (strcmp(addr, inet_ntop(AF_INET, &ip, str, sizeof(str))) != 0) {
RETURN_FALSE;
}
#endif
RETURN_LONG(ntohl(ip.s_addr));
}
/* }}} */
Expand Down
Loading