dhcp: test root domain for DNSSL/radvd

PR: https://github.com/opnsense/core/issues/6529
This commit is contained in:
Franco Fichtner 2023-04-28 08:44:51 +02:00
parent c6d4ffd5e0
commit 1ff709dc91
2 changed files with 7 additions and 6 deletions

View File

@ -744,16 +744,17 @@ function is_hostname($hostname)
}
/* returns true if $domain is a valid domain name */
function is_domain($domain)
function is_domain($domain, $allow_root = false)
{
if (!is_string($domain)) {
return false;
}
if (preg_match('/^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i', $domain)) {
} elseif (preg_match('/^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i', $domain)) {
return true;
} elseif ($allow_root && $domain == '.') {
return true;
} else {
return false;
}
return false;
}
/* returns true if $macaddr is a valid MAC address */

View File

@ -118,7 +118,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($pconfig['radomainsearchlist'])) {
$domain_array=preg_split("/[ ;]+/",$pconfig['radomainsearchlist']);
foreach ($domain_array as $curdomain) {
if (!is_domain($curdomain)) {
if (!is_domain($curdomain, true)) {
$input_errors[] = gettext("A valid domain search list must be specified.");
break;
}