Fix cidr_match() for IPv6 with PHP 7.1

With PHP 7.1 implicit conversion of non-trimmed strings to integer raises an error. Input value fpr IPv6 subnets is now trimmed and a check for numeric value is added.
This commit is contained in:
Stefan Kalscheuer 2017-07-15 17:50:55 +02:00
parent 5f2d883186
commit 3206da2861

View File

@ -287,7 +287,13 @@ class StatifyBlacklist {
}
if ( false !== strpos( $net, '/' ) ) { // Parse CIDR subnet.
list( $base, $mask ) = explode( '/', $net, 2 );
list( $base, $mask ) = explode( '/', trim( $net ), 2 );
if ( ! is_numeric( $mask ) ) {
return false;
} else {
$mask = (int) $mask;
}
if ( $mask < 1 || $mask > 128 ) {
return false;