diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-01 14:21:22 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-01-01 14:21:22 +0545 |
commit | 49ad2c22b1600c09e543ed244e1b21c6b41d105b (patch) | |
tree | 09da8ac2434b9a73d46033c0239b96eb5933e88a | |
parent | c7cd5f1c5eb92eff8cf557a8def7fdf66eb9734e (diff) | |
download | pfsense-49ad2c22b1600c09e543ed244e1b21c6b41d105b.zip pfsense-49ad2c22b1600c09e543ed244e1b21c6b41d105b.tar.gz |
Fix redmine #5722 DHCP validation for RELENG_2_2
Might as well provide the fixes for RELENG_2_2 since it is easy and that is where I first tested. Even if there is never a 2.2.7, at least the fixes are there in GitHub to be seen.
-rw-r--r-- | usr/local/www/services_dhcp.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php index fdd1d43..70b249e 100644 --- a/usr/local/www/services_dhcp.php +++ b/usr/local/www/services_dhcp.php @@ -104,6 +104,11 @@ if (is_array($config['dhcpd'][$if])){ $dhcpdconf = array(); else $dhcpdconf = &$config['dhcpd'][$if]; + + if (!is_array($config['dhcpd'][$if]['staticmap'])) { + $dhcpdconf['staticmap'] = array(); + } + $a_maps = &$config['dhcpd'][$if]['staticmap']; } if (is_array($dhcpdconf)) { // Global Options @@ -123,10 +128,6 @@ if (is_array($dhcpdconf)) { } $pconfig['dhcpleaseinlocaltime'] = $dhcpleaseinlocaltime; - - if (!is_array($dhcpdconf['staticmap'])) - $dhcpdconf['staticmap'] = array(); - $a_maps = &$dhcpdconf['staticmap']; } else { // Options that exist only in pools $pconfig['descr'] = $dhcpdconf['descr']; @@ -341,16 +342,18 @@ if (isset($_POST['submit'])) { $rfrom = $config['dhcpd'][$if]['range']['from']; $rto = $config['dhcpd'][$if]['range']['to']; - if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto)) + if (!((ip2ulong($_POST['range_from']) > ip2ulong($rto)) || + (ip2ulong($_POST['range_to']) < ip2ulong($rfrom)))) { $input_errors[] = gettext("The specified range must not be within the DHCP range for this interface."); + } } foreach ($a_pools as $id => $p) { if (is_numeric($pool) && ($id == $pool)) continue; - if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) || - is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) { + if (!((ip2ulong($_POST['range_from']) > ip2ulong($p['range']['to'])) || + (ip2ulong($_POST['range_to']) < ip2ulong($p['range']['from'])))) { $input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface."); break; } @@ -366,8 +369,8 @@ if (isset($_POST['submit'])) { foreach ($a_maps as $map) { if (empty($map['ipaddr'])) continue; - if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) && - (ip2ulong($map['ipaddr']) < $dynsubnet_end)) { + if ((ip2ulong($map['ipaddr']) >= $dynsubnet_start) && + (ip2ulong($map['ipaddr']) <= $dynsubnet_end)) { $input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings.")); break; } |