#42512 [Asn->Csd]: ip2long('255.255.255.255') should return 4294967295 on 64-bit PHP

From: Date: Sat, 01 Sep 2007 18:38:53 +0000
Subject: #42512 [Asn->Csd]: ip2long('255.255.255.255') should return 4294967295 on 64-bit PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116964@lists.php.net to get a copy of this message
ID: 42512 Updated by: derick@php.net Reported By: jr-php2 at quo dot to -Status: Assigned +Status: Closed Bug Type: Network related Operating System: Linux x86-64 PHP Version: 5.2.4 Assigned To: derick New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-09-01 18:29:38] derick@php.net Confirmed, and testing a patch. ------------------------------------------------------------------------ [2007-09-01 18:10:25] jr-php2 at quo dot to Description: ------------ On 64-bit platforms, ip2long() returns a positive result for IP addresses >= 128.0.0.0. This is expected. However, there is *one* case in which it will return a negative result: when the specified address is 255.255.255.255. This inconsistency doesn't make sense. Yes, the documentation does say that ip2long() returns -1 for 255.255.255.255, but that should only be the case on 32-bit platforms, where all addresses >= 128.0.0.0 return a negative result. Reproduce code: --------------- echo "ip2long('255.255.255.254') = ", ip2long('255.255.255.254'), "\n"; echo "ip2long('255.255.255.255') = ", ip2long('255.255.255.255'), "\n"; Expected result: ---------------- ip2long('255.255.255.254') = 4294967294 ip2long('255.255.255.255') = 4294967295 Actual result: -------------- ip2long('255.255.255.254') = 4294967294 ip2long('255.255.255.255') = -1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42512&edit=1

« previous php.bugs (#116964) next »