diff options
-rw-r--r-- | etc/inc/util.inc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 8e3eed7..e65d52c 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -761,13 +761,14 @@ function check_subnetsv6_overlap($subnet1, $bits1, $subnet2, $bits2) { /* return true if $addr is in $subnet, false if not */ function ip_in_subnet($addr,$subnet) { - if(is_ipaddrv6($addr)) { + if(is_ipaddrv6($addr) && is_subnetv6($subnet)) { return (Net_IPv6::isInNetmask($addr, $subnet)); - } else { /* XXX: Maybe check for IPv4 */ + } else if (is_ipaddrv4($addr) && is_subnetv4($subnet)) { list($ip, $mask) = explode('/', $subnet); $mask = (0xffffffff << (32 - $mask)) & 0xffffffff; return ((ip2long($addr) & $mask) == (ip2long($ip) & $mask)); } + return false; } /* returns true if $hostname is just a valid hostname (top part without any of the domain part) */ |