Edit report at https://bugs.php.net/bug.php?id=55472&edit=1
ID: 55472
User updated by: php at linuxhosted dot ca
Reported by: php at linuxhosted dot ca
Summary: ip2long(integer) returns integer
Status: Assigned
Type: Bug
Package: *Network Functions
Operating System: Windows
PHP Version: 5.3.7
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
As we've been saying, the fact that this function uses a Windows specific api
is the bug. It should be using inet_ntop/pton like every other OS does. Also,
you say that "26" is a valid IP, which is totally wrong, the function considers
26 to be "0.0.0.26", when if it was taking it as a valid ip, it would mean that
its "26.0.0.0, take for example, long2ip(ip2long("10.200")); this becomes
10.0.0.200, instead of what it should be, 10.200.0.0.
Also, it makes no sense for a function that is not OS specific to have
different results on different platforms, PHP is supposed to be multi-platform,
so except for functions that are meant to be platform specific , functions
shouldn't be giving a totally different result on different platforms, it just
makes no sense.
Previous Comments:
------------------------------------------------------------------------
[2011-08-23 16:16:53] [email protected]
It is as it can be considered as valid IP and it is what happens on Windows,
using
the underlying equivalent API.
That being said, I will double check again with the inent team at msft to be
sure
that there is no bug in the API itself.
assigned to me.
------------------------------------------------------------------------
[2011-08-23 16:09:32] php at linuxhosted dot ca
pajoye, this is not a documentation bug
------------------------------------------------------------------------
[2011-08-23 15:10:29] php at linuxhosted dot ca
As kalle has said, this is not a documentation bug. The inet_ntop() and
inet_pton() functions have existed on Windows since 5.3
------------------------------------------------------------------------
[2011-08-22 13:55:44] [email protected]
(Ignore the assigned status laruence, just to notify you)
We do have inet_ntop() + inet_pton() on Windows, see win32/inet.c which we
implemented in 5.3 so if thats the case that we fall back to inet_addr() on
Windows its a bug as they are natively implemented.
After it might be worth setting this bug to "To be documented" so the behaviour
can indeed be noted if not already in the manual.
------------------------------------------------------------------------
[2011-08-21 10:10:40] [email protected]
in the OS without inet_ntop, php ip2long use inet_addr handle the conversion,
obviously there are difference between these two function when meet a not well-
format numbers-and-dots notation.
http://www.kernel.org/doc/man-pages/online/pages/man3/inet_pton.3.html
http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/libs/commtrf2/inet_addr.
htm
maybe the document should be more clearly to explain the difference?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=55472
--
Edit this bug report at https://bugs.php.net/bug.php?id=55472&edit=1