|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64395 Wrong result
Submitted: 2013-03-08 19:54 UTC Modified: 2013-06-19 12:15 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 2 (0.0%)
From: abc905 at mail dot ru Assigned:
Status: Wont fix Package: Network related
PHP Version: 5.4.13 OS: Windows 7 x64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-03-08 19:54 UTC] abc905 at mail dot ru
It seems ip2long function returns wrong result instead of when convert ip address like ''

Thank you,

From manual page:

Test script:
$ip = '';
$ip_long = sprintf("%u", ip2long($ip));
print long2ip($ip_long);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-17 02:39 UTC] pete at petermcdonald dot co dot uk
I have tried to reproduce on php 5.4.11 (zend server install) using code specified 
but output is expected
 [2013-03-21 16:11 UTC] abc905 at mail dot ru
Unfortunatly my output is wrong

PHP. Ver.  5.4.11 (Open Server Win7 x64) and 5.4.9 (Windows Installer install)
Output: -> -> ->
Looks like long2ip() converts segments with leading zero as octal.
 [2013-03-28 15:48 UTC] abc905 at mail dot ru
-PHP Version: 5.4.12 +PHP Version: 5.4.13
 [2013-03-28 15:48 UTC] abc905 at mail dot ru
PHP. Ver.  5.4.13 (Open Server Win7 x64)
Output: -> -> ->
Looks like long2ip() converts segments with leading zero as octal.
 [2013-04-21 12:37 UTC] sjon at hortensius dot net
Php interprets numbers with leading zeros as octal [1]. Octal 011 = Decimal 9. 
Also, I think this is not a valid IP address notation.

This is fixed in newer PHP versions, where this format is rejected and false is 
returned; see

 [2013-06-19 12:15 UTC]
-Status: Open +Status: Wont fix
 [2013-06-19 12:15 UTC]
This won't fix in 5.4 - the native inet_pton platform implementation is available starting with windows vista , in 5.4 however windows xp support is guaranteed.

In 5.5 the sdk implementation is used, which validates this issue as fixed there. Prior to that PHP own inet_pton implementation is used, 
which isn't perfect. However the case you brought is just one of many more complicated, imagine one would use a hex notation for 
segments including upper and lower letter case. Parsing this is much more complicated and facing the fact it's fixed in 5.5 I'm really not 
sure it's worth to touch 5.4.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 21:01:32 2024 UTC