-
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,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) { | ||
|
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. quick question: is
Author
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. Yes, inet_ntop is available
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. I think it is preferable over inet_ntoa. I know it s easier, but it is also deprecated.
Author
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. I will update the code to use inet_ntop instead of inet_ntoa. |
||
| 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.
If such function is expected, it should be tested.