Permalink
Browse files

subnet address: MDL-19509 make subnet matching work with 0.0.0.0/0

Merged from MOODLE_18_STABLE
  • Loading branch information...
1 parent 7d8b34d commit 656ff52256c0647cfcf5e6d02859c073697e37e1 iarenaza committed Jun 18, 2009
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/moodlelib.php
View
@@ -7245,7 +7245,11 @@ function address_in_subnet($addr, $subnetstr) {
if ($mask === '' || $mask > 32) {
$mask = 32;
}
- $mask = 0xffffffff << (32 - $mask);
+ // When $mask is zero, PHP's integer arithmetic gives us a mask
+ // of 255.255.255.255 instead of 0.0.0.0, so special case it
+ if ($mask != 0) {
+ $mask = 0xffffffff << (32 - $mask);
+ }
$found = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
} else if (strpos($subnet, '-') !== false) {/// type 3
$subnetparts = explode('.', $subnet);

0 comments on commit 656ff52

Please sign in to comment.