PHP 4.0 Bug #8217 Updated: long2ip gives 127.255.255.255 result instead of correct value

From: Date: Wed, 13 Dec 2000 11:35:01 +0000
Subject: PHP 4.0 Bug #8217 Updated: long2ip gives 127.255.255.255 result instead of correct value
Groups: php.dev 
Request: Send a blank email to php-dev+get-41159@lists.php.net to get a copy of this message
ID: 8217 Updated by: stas Reported By: christoph@lameter.com Status: Open Old-Bug Type: Network related Bug Type: Feature/Change Request Assigned To: Comments: Numbers you brought are not valid PHP longs, they don't fit signed long. So they don't give good result in long2ip. It might be done with a special hack, but it's not a bug - it's a lacking feature. Previous Comments: --------------------------------------------------------------------------- [2000-12-12 18:43:49] christoph@lameter.com 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"; } ?> --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8217

« previous php.dev (#41159) next »