summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorstilez <stilez@users.noreply.github.com>2015-12-25 20:02:23 +0000
committerstilez <stilez@users.noreply.github.com>2015-12-25 20:02:23 +0000
commitec513fa9b85f1456d0af739d4f1c305abaecbbe7 (patch)
treeaf8c7a307f35be48bce2d2fe73d320959c9431a7 /src/usr
parent99c1e285030ff6c4f39da1b463b34a1fea01ad3f (diff)
downloadpfsense-ec513fa9b85f1456d0af739d4f1c305abaecbbe7.zip
pfsense-ec513fa9b85f1456d0af739d4f1c305abaecbbe7.tar.gz
Redundant logic tests in a range check
The logic here is redundant. It tests IP1<START || IP2<START || IP1>END || IP2>END. *Then* it tests if IP1<IP2 unsigned. If the latter test succeeds (ie test that first) then IP1>=START *must imply* IP2>=START and IP2<=END *must imply* IP1<=END. In other words we only need to test: START <= IP1 <= IP2 <= END, ie 3 logic tests (IP1<=IP2 && IP1>=START && IP2<=END) not 5 logic tests.
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/local/www/services_dhcp.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php
index 657cbc8..a30a488 100644
--- a/src/usr/local/www/services_dhcp.php
+++ b/src/usr/local/www/services_dhcp.php
@@ -403,15 +403,14 @@ if (isset($_POST['submit'])) {
$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
- if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
- (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
- $input_errors[] = gettext("The specified range lies outside of the current subnet.");
- }
-
if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to'])) {
$input_errors[] = gettext("The range is invalid (first element higher than second element).");
}
+ if (ip2ulong($_POST['range_from']) < $subnet_start || ip2ulong($_POST['range_to']) > $subnet_end) {
+ $input_errors[] = gettext("The specified range lies outside of the current subnet.");
+ }
+
if (is_numeric($pool) || ($act == "newpool")) {
$rfrom = $config['dhcpd'][$if]['range']['from'];
$rto = $config['dhcpd'][$if]['range']['to'];
OpenPOWER on IntegriCloud