From: Roan Kattouw Date: Sun, 31 May 2009 14:52:16 +0000 (+0000) Subject: Fix weird bug that caused IP::isInRange("80.0.0.0", "94.0.0.0/24") to return true... X-Git-Tag: 1.31.0-rc.0~41591 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=e7f76a6e773e46987e86dae95507309470bd886b;p=lhc%2Fweb%2Fwiklou.git Fix weird bug that caused IP::isInRange("80.0.0.0", "94.0.0.0/24") to return true because "52000000" >= "5E000000" (52000000 >= 5). Thanks, PHP. --- diff --git a/includes/IP.php b/includes/IP.php index a2085421dc..355c7b68b3 100644 --- a/includes/IP.php +++ b/includes/IP.php @@ -502,9 +502,10 @@ class IP { */ public static function isInRange( $addr, $range ) { // Convert to IPv6 if needed - $unsignedIP = self::toHex( $addr ); + $unsignedIP = self::toUnsigned( $addr ); list( $start, $end ) = self::parseRange( $range ); - return (($unsignedIP >= $start) && ($unsignedIP <= $end)); + return (($unsignedIP >= base_convert($start, 16, 10)) && + ($unsignedIP <= base_convert($end, 16, 10))); } /**