Skip to content

Commit f064194

Browse files
committed
Add numerical check for subnet (#5975)
1 parent 416c9fa commit f064194

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

interface/lib/classes/validate_dns.inc.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ function validate_ip($field_name, $field_value, $validator) {
310310
if(strpos($ip, '/') !== false) {
311311
list($ip, $subnet) = explode('/', $ip, 2);
312312
$ip = trim($ip);
313-
$subnet = intval($subnet);
314313
}
315314
if(function_exists('filter_var')) {
316315
if(!filter_var($ip, FILTER_VALIDATE_IP)) {
@@ -320,7 +319,11 @@ function validate_ip($field_name, $field_value, $validator) {
320319
} else $this->errorMessage .= "function filter_var missing <br />\r\n";
321320
// Check if the range is valid
322321
if ($subnet !== '') {
323-
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
322+
if (!is_numeric($subnet)) {
323+
$errmsg = $validator['errmsg'];
324+
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
325+
}
326+
elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
324327
if ($subnet < 1 || $subnet > 128) {
325328
$errmsg = $validator['errmsg'];
326329
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";

0 commit comments

Comments
 (0)