From f064194e003f579933193424a5f66fc163202f60 Mon Sep 17 00:00:00 2001 From: Thom Pol Date: Tue, 22 Dec 2020 22:40:08 +0100 Subject: [PATCH] Add numerical check for subnet (#5975) --- interface/lib/classes/validate_dns.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/lib/classes/validate_dns.inc.php b/interface/lib/classes/validate_dns.inc.php index c4b94b5f77..15d670d84a 100644 --- a/interface/lib/classes/validate_dns.inc.php +++ b/interface/lib/classes/validate_dns.inc.php @@ -310,7 +310,6 @@ class validate_dns { if(strpos($ip, '/') !== false) { list($ip, $subnet) = explode('/', $ip, 2); $ip = trim($ip); - $subnet = intval($subnet); } if(function_exists('filter_var')) { if(!filter_var($ip, FILTER_VALIDATE_IP)) { @@ -320,7 +319,11 @@ class validate_dns { } else $this->errorMessage .= "function filter_var missing
\r\n"; // Check if the range is valid if ($subnet !== '') { - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + if (!is_numeric($subnet)) { + $errmsg = $validator['errmsg']; + $errorMessage .= $app->tform->lng($errmsg)."
\r\n"; + } + elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if ($subnet < 1 || $subnet > 128) { $errmsg = $validator['errmsg']; $errorMessage .= $app->tform->lng($errmsg)."
\r\n"; -- GitLab