summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
Diffstat (limited to 'it.class')
-rw-r--r--it.class2
1 files changed, 1 insertions, 1 deletions
diff --git a/it.class b/it.class
index 38421b4..cfad675 100644
--- a/it.class
+++ b/it.class
@@ -325,7 +325,7 @@ function cidr_match($ip, $cidr)
list($subnet, $mask) = explode('/', $cidr);
$ip_bin = inet_pton($ip);
$subnet_bin = inet_pton($subnet);
- $valid_bytes = $mask >> 3;
+ $valid_bytes = $mask ? $mask >> 3 : 42;
$bitmask = 256 - (1 << (8 - ($mask & 7)));
$lastbyte_matched = $bitmask ? (ord($ip_bin{$valid_bytes}) & $bitmask) == (ord($subnet_bin{$valid_bytes}) & $bitmask) : true;
return substr($ip_bin, 0, $valid_bytes) == substr($subnet_bin, 0, $valid_bytes) && $lastbyte_matched;