|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
20 + 12 = ?
Subscribe to this entry?

 [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-2022 The PHP Group
All rights reserved.
Last updated: Fri Sep 30 22:05:55 2022 UTC