From 84d1be538e9d20386e3654b59fadef7941af78ff Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 28 Oct 2019 13:25:34 +0100 Subject: [PATCH] block ipv6 addresses in cidr notation (mysql can't handle it) --- lib/Froxlor/Validate/Validate.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Froxlor/Validate/Validate.php b/lib/Froxlor/Validate/Validate.php index 3fd0d410..bf9ef268 100644 --- a/lib/Froxlor/Validate/Validate.php +++ b/lib/Froxlor/Validate/Validate.php @@ -106,7 +106,11 @@ class Validate if ($allow_cidr) { $org_ip = $ip; $ip_cidr = explode("/", $ip); - if (count($ip_cidr) == 2) { + if (count($ip_cidr) === 2) { + //MySQL does not handle CIDR of IPv6 addresses, return error + if (false === filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + \Froxlor\UI\Response::standard_error($lng, $ip, $throw_exception); + } $ip = $ip_cidr[0]; if (strlen($ip_cidr[1]) <= 2) { $ip_cidr[1] = self::cidr2NetmaskAddr($org_ip);