Fix ip2long in AIX to treat IPs with leading zeros as invalid like LINUX#21296
Fix ip2long in AIX to treat IPs with leading zeros as invalid like LINUX#21296reshmavk wants to merge 4 commits intophp:PHP-8.4from
Conversation
ext/standard/basic_functions.c
Outdated
| 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) { |
There was a problem hiding this comment.
quick question: is inet_ntop available on AIX ?
There was a problem hiding this comment.
I think it is preferable over inet_ntoa. I know it s easier, but it is also deprecated.
There was a problem hiding this comment.
I will update the code to use inet_ntop instead of inet_ntoa.
ext/standard/basic_functions.c
Outdated
| AIX accepts IP strings with excedentary 0 (192.168.042.42 will be treated as | ||
| 192.168.42.42), while Linux don't. |
There was a problem hiding this comment.
If such functionality is expected, it should be tested.
|
Looks like you accidentally swallowed your changes with the last commit. There is a slight indentation issue with the new var declaration. You would probably need to guard the said var to be aix exclusive to avoid unused var build warnings for everything else. |
|
Also as @mvorisek mentioned a new test for provability sake would be nice ;) |
|
There is an existing testcase that covers IPs with leading zeros - ext/standard/tests/network/ip2long_variation2_x64.phpt. This was failing earlier and is now passing with the fix.
|
ext/standard/basic_functions.c
Outdated
| RETURN_FALSE; | ||
| } | ||
| #ifdef _AIX | ||
| /* |
There was a problem hiding this comment.
the diff show indentation misalignment (see the line above).
ext/standard/basic_functions.c
Outdated
| RETURN_FALSE; | ||
| } | ||
| #ifdef _AIX | ||
| /* |
There was a problem hiding this comment.
sorry to annoy you again but the indentation is still off.
There was a problem hiding this comment.
Thanks for your patience. I’ll update the indentation so that #ifdef and #endif have no indentation, and ensure the lines within that block align with the code around line 600.
Fixes #21295