summaryrefslogtreecommitdiffstats
path: root/src/etc/inc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-03-27 14:24:40 -0300
committerRenato Botelho <renato@netgate.com>2017-03-27 14:24:40 -0300
commitd52aed62354f2ec550c06553f0bc54ffb9d971aa (patch)
tree01e14e56eccd16b2d271d80139ac6dea35e3574b /src/etc/inc
parent74d259a6e897a49bcf728843600587bd2ea035f2 (diff)
parentfe108b671d09cf34a11270e286dcd4c4ce1c0597 (diff)
downloadpfsense-d52aed62354f2ec550c06553f0bc54ffb9d971aa.zip
pfsense-d52aed62354f2ec550c06553f0bc54ffb9d971aa.tar.gz
Merge pull request #3677 from phil-davis/handle-empty-port-alias-refactor
Diffstat (limited to 'src/etc/inc')
-rw-r--r--src/etc/inc/filter.inc6
-rw-r--r--src/etc/inc/pfsense-utils.inc2
-rw-r--r--src/etc/inc/util.inc21
3 files changed, 16 insertions, 13 deletions
diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc
index 7f64540..d940442 100644
--- a/src/etc/inc/filter.inc
+++ b/src/etc/inc/filter.inc
@@ -636,7 +636,7 @@ function filter_generate_nested_alias_recurse($name, $alias, &$aliasnesting, &$a
$tmpline = filter_generate_nested_alias_recurse($name, $aliastable[$address], $aliasnesting, $aliasaddrnesting, $use_filterdns);
}
} else if (!isset($aliasaddrnesting[$address])) {
- if (!is_ipaddr($address) && !is_subnet($address) && !((($alias_type == 'port') || ($alias_type == 'url_ports')) && is_portorrange($address)) && is_hostname($address)) {
+ if (!is_ipaddr($address) && !is_subnet($address) && !((($alias_type == 'port') || ($alias_type == 'url_ports')) && is_port_or_range($address)) && is_hostname($address)) {
if (!isset($filterdns["{$address}{$name}"])) {
$use_filterdns = true;
$filterdns["{$address}{$name}"] = "pf {$address} {$name}\n";
@@ -2710,7 +2710,7 @@ function filter_generate_user_rule($rule) {
return "# {$error_text}";
}
if ($rule['source']['port']
- && !is_portorrange(str_replace("-", ":", $rule['source']['port']))) {
+ && !is_port_or_range(str_replace("-", ":", $rule['source']['port']))) {
$error_text = "";
// It is not a literal port or port range, so alias should exist, and expand to something non-empty
@@ -2726,7 +2726,7 @@ function filter_generate_user_rule($rule) {
}
}
if ($rule['destination']['port']
- && !is_portorrange(str_replace("-", ":", $rule['destination']['port']))) {
+ && !is_port_or_range(str_replace("-", ":", $rule['destination']['port']))) {
$error_text = "";
// It is not a literal port or port range, so alias should exist, and expand to something non-empty
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc
index 83b2f5a..81a2ea3 100644
--- a/src/etc/inc/pfsense-utils.inc
+++ b/src/etc/inc/pfsense-utils.inc
@@ -2153,7 +2153,7 @@ function parse_aliases_file($filename, $type = "url", $max_items = -1, $kflc = f
$tmp = $tmp_str;
}
$valid = (($type == "url" || $type == "urltable") && (is_ipaddr($tmp) || is_subnet($tmp))) ||
- (($type == "url_ports" || $type == "urltable_ports") && is_portorrange($tmp));
+ (($type == "url_ports" || $type == "urltable_ports") && is_port_or_range($tmp));
if ($valid) {
$items[] = $tmp;
if (count($items) == $max_items) {
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index 76410b4..74ffd9f 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -1125,12 +1125,12 @@ function is_portrange($portrange) {
}
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") */
-function is_portorrange($port) {
+function is_port_or_range($port) {
return (is_port($port) || is_portrange($port));
}
-/* returns true if $port is a valid port number or an alias thereof */
-function is_portoralias($port) {
+/* returns true if $port is an alias that is a port type */
+function is_portalias($port) {
global $config;
if (is_alias($port)) {
@@ -1141,15 +1141,18 @@ function is_portoralias($port) {
}
}
}
- return false;
- } else {
- return is_port($port);
}
+ return false;
+}
+
+/* returns true if $port is a valid port number or an alias thereof */
+function is_port_or_alias($port) {
+ return (is_port($port) || is_portalias($port));
}
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") or an alias thereof */
-function is_portorrangeoralias($port) {
- return (is_portoralias($port) || is_portrange($port));
+function is_port_or_range_or_alias($port) {
+ return (is_port($port) || is_portrange($port) || is_portalias($port));
}
/* create ranges of sequential port numbers (200:215) and remove duplicates */
@@ -1791,7 +1794,7 @@ function alias_expand($name) {
}
}
return "\${$name}";
- } else if (is_ipaddr($name) || is_subnet($name) || is_portorrange($name)) {
+ } else if (is_ipaddr($name) || is_subnet($name) || is_port_or_range($name)) {
return "{$name}";
} else {
return null;
OpenPOWER on IntegriCloud