From c9bd89752bc76c9d4112e12cdd7c308330df835f Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 25 Jul 2023 09:13:45 +0200 Subject: [PATCH] wizard: restrict to validating IPv4; closes #6681 The system wizard is IPv4 only but doesn't use the correct function. It's debatable if we need to restrict DNS servers but if all of this is only IPv4 we should stick to it in a consistsent way. --- src/wizard/system.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wizard/system.xml b/src/wizard/system.xml index 828356ed4..496d408b0 100644 --- a/src/wizard/system.xml +++ b/src/wizard/system.xml @@ -146,10 +146,10 @@ if (empty($_POST['hostname']) || !is_hostname($_POST['hostname'])) { if (empty($_POST['domain']) || !is_domain($_POST['domain'])) { $input_errors[] = gettext('Domain is invalid.'); } -if (!empty($_POST['primarydnsserver']) && !is_ipaddr($_POST['primarydnsserver'])) { +if (!empty($_POST['primarydnsserver']) && !is_ipaddrv4($_POST['primarydnsserver'])) { $input_errors[] = gettext('Primary DNS server is invalid.'); } -if (!empty($_POST['secondarydnsserver']) && !is_ipaddr($_POST['secondarydnsserver'])) { +if (!empty($_POST['secondarydnsserver']) && !is_ipaddrv4($_POST['secondarydnsserver'])) { $input_errors[] = gettext('Second DNS server is invalid.'); } if (!empty($input_errors)) { @@ -436,7 +436,7 @@ if (!empty($_POST['macaddress']) && !is_macaddr($_POST['macaddress'])) { $input_errors[] = gettext('Invalid MAC address.'); } if (!empty($_POST['ipaddress']) && ($_POST['selectedtype'] == "Static")) { - if (!is_ipaddr($_POST['ipaddress'])) { + if (!is_ipaddrv4($_POST['ipaddress'])) { $input_errors[] = gettext('Invalid WAN IP address.'); } if ($_POST['subnetmask'] < 31 && @@ -448,10 +448,10 @@ if (!empty($_POST['ipaddress']) && ($_POST['selectedtype'] == "Static")) { if (!empty($_POST['dhcphostname']) && !is_hostname($_POST['dhcphostname'])) { $input_errors[] = gettext('Invalid DHCP hostname.'); } -if (!empty($_POST['pptplocalipaddress']) && !is_ipaddr($_POST['pptplocalipaddress'])) { +if (!empty($_POST['pptplocalipaddress']) && !is_ipaddrv4($_POST['pptplocalipaddress'])) { $input_errors[] = gettext('Invalid PPTP Local IP address.'); } -if (!empty($_POST['pptpremoteipaddress']) && !is_ipaddr($_POST['pptpremoteipaddress'])) { +if (!empty($_POST['pptpremoteipaddress']) && !is_ipaddrv4($_POST['pptpremoteipaddress'])) { $input_errors[] = gettext('Invalid PPTP Remote IP address.'); } if (!empty($input_errors)) { @@ -529,7 +529,7 @@ if ($_POST['selectedtype'] != "Static") {