diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-12-30 16:34:18 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-12-30 16:34:59 +0000 |
commit | 231e060664779b0349e93a84b72dab322c3f8fb8 (patch) | |
tree | 91225de22f349bb71edeb5006ce592222e83d33d /etc/inc/util.inc | |
parent | 0c8d27635cfe61d746dd756f6cd29866252831a0 (diff) | |
download | pfsense-231e060664779b0349e93a84b72dab322c3f8fb8.zip pfsense-231e060664779b0349e93a84b72dab322c3f8fb8.tar.gz |
Ticket #261 Do not consider ports as hostnames. This changes the is_port function to consider ':'(ranges) as ports. This seems a previous feature i do not agree with much, but users decide right?!
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 169fb7d..498f14a 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -300,14 +300,16 @@ function is_validaliasname($name) { /* returns true if $port is a valid TCP/UDP port */ function is_port($port) { - if (getservbyname($port, "tcp") || getservbyname($port, "udp")) - return true; - if (!ctype_digit($port)) - return false; - if ((intval($port) < 1) || (intval($port) > 65535)) - return false; - else - return true; + $tmpports = explode(":", $port); + foreach($tmpports as $tmpport) { + if (getservbyname($tmpport, "tcp") || getservbyname($tmpport, "udp")) + continue; + if (!ctype_digit($tmpport)) + return false; + else if ((intval($port) < 1) || (intval($port) > 65535)) + return false; + } + return true; } /* returns true if $portrange is a valid TCP/UDP portrange ("<port>:<port>") */ |