|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17202 long2ip problems with unsigned double
Submitted: 2002-05-14 07:13 UTC Modified: 2002-07-01 15:38 UTC
From: pl at dlh dot net Assigned:
Status: Not a bug Package: Network related
PHP Version: 4.2.0 OS: Debian 3.0 / Kernel 2.4.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: pl at dlh dot net
New email:
PHP Version: OS:


 [2002-05-14 07:13 UTC] pl at dlh dot net
When storing ips as unsigned doubles I noticed a strange behaviour when passing unsigned doubles through the long2ip routine.

-- sample --


$ip = ip2long("");

print long2ip($ip)."\n";

if ($ip < 0) $ip+=pow(2,32);  //convert from signed to unsigned

print long2ip($ip)."\n";


-- end ---

In the first line - as supposed - the script returns "", but after conversion I get an offset by one and it returns "". I read in the doc that long2ip is capable of handling both signed and unsigned long integers.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-01 15:36 UTC]
PHP has no unsigned numbers, so $ip+=pow(2,32); will mess up (goes beyond the limits of PHP's INT). Not a bug.
 [2002-07-01 15:38 UTC]
Your test script prints this for me with PHP 4.3.0-dev too:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 16 02:03:34 2021 UTC