PHP 4.0 Bug #8217: long2ip gives 127.255.255.255 result instead of correct value
| From: | christoph at lameter dot com | Date: | Tue, 12 Dec 2000 23:43:49 +0000 |
| Subject: | PHP 4.0 Bug #8217: long2ip gives 127.255.255.255 result instead of correct value | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-41094@lists.php.net to get a copy of this message | ||
From: christoph@lameter.com
Operating system: Linux
PHP version: 4.0.3pl1
PHP Bug Type: Network related
Bug description: long2ip gives 127.255.255.255 result instead of correct value
Feed the following list to this script and you will see how long2ip screws up. There is an overflow
condition it seems:
178519801
1061963075
1070665698
1070668067
2180645450
2180645574
2180645666
2180645722
2180647266
2180648705
2180649062
2180652350
2180676205
2301042637
2554268534
2554278550
2554279006
3232238083
3232238334
3435825182
3435825736
3475085569
3506496261
3508072161
3522432302
3528459286
3528470646
3528471070
<?php
function lng2ip($ip) {
settype($ip,"double");
return floor($ip/(256*256*256)) . "." . floor($ip/(256*256))%256 . "." .
floor($ip/256)%256 . "." .
}
$fh=fopen("xx","r");
while ($x=fgets($fh,100)) {
$x=rtrim ($x);
echo "$x ".long2ip($x)." ".lng2ip($x)."\n";
}
?>
--
Edit Bug report at: http://bugs.php.net/?id=8217&edit=1