From e7f76a6e773e46987e86dae95507309470bd886b Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 31 May 2009 14:52:16 +0000 Subject: [PATCH] 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. --- includes/IP.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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))); } /** -- 2.20.1