-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix ip2long in AIX to treat IPs with leading zeros as invalid like LINUX #21296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: PHP-8.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -598,6 +598,18 @@ 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in theory |
||
| RETURN_FALSE; | ||
| } | ||
| #endif | ||
| RETURN_LONG(ntohl(ip.s_addr)); | ||
| } | ||
| /* }}} */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
excedentary=>extraneous.