mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Fix OpenVPN server port validation to disallow "0". 0 is still OK for client port, which is the same meaning as blank/empty. Fixes #7565
This commit is contained in:
parent
bc3669e4e8
commit
39fed38653
@ -509,10 +509,13 @@ function openvpn_validate_host($value, $name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function openvpn_validate_port($value, $name) {
|
||||
function openvpn_validate_port($value, $name, $first_port = 0) {
|
||||
$value = trim($value);
|
||||
if (empty($value) || !is_numeric($value) || $value < 0 || ($value > 65535)) {
|
||||
return sprintf(gettext("The field '%s' must contain a valid port, ranging from 0 to 65535."), $name);
|
||||
if (!is_numeric($first_port)) {
|
||||
$first_port = 0;
|
||||
}
|
||||
if (empty($value) || !is_numeric($value) || $value < $first_port || ($value > 65535)) {
|
||||
return sprintf(gettext("The field '%s' must contain a valid port, ranging from {$first_port} to 65535."), $name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ if ($_POST['save']) {
|
||||
}
|
||||
|
||||
/* input validation */
|
||||
if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) {
|
||||
if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port', 1)) {
|
||||
$input_errors[] = $result;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user