php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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 --

<?php

$ip = ip2long("192.168.0.1");

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 "192.168.0.1", but after conversion I get an offset by one and it returns "192.168.0.0". I read in the doc that long2ip is capable of handling both signed and unsigned long integers.

Peter

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-01 15:36 UTC] sander@php.net
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] derick@php.net
Your test script prints this for me with PHP 4.3.0-dev too:

192.168.0.1
192.168.0.1
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Nov 12 05:01:32 2019 UTC