Project

General

Profile

« Previous | Next » 

Revision 39fed386

Added by Jim Pingle about 8 years ago

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

View differences:

src/etc/inc/openvpn.inc
509 509
	return false;
510 510
}
511 511

  
512
function openvpn_validate_port($value, $name) {
512
function openvpn_validate_port($value, $name, $first_port = 0) {
513 513
	$value = trim($value);
514
	if (empty($value) || !is_numeric($value) || $value < 0 || ($value > 65535)) {
515
		return sprintf(gettext("The field '%s' must contain a valid port, ranging from 0 to 65535."), $name);
514
	if (!is_numeric($first_port)) {
515
		$first_port = 0;
516
	}
517
	if (empty($value) || !is_numeric($value) || $value < $first_port || ($value > 65535)) {
518
		return sprintf(gettext("The field '%s' must contain a valid port, ranging from {$first_port} to 65535."), $name);
516 519
	}
517 520
	return false;
518 521
}
src/usr/local/www/vpn_openvpn_server.php
295 295
	}
296 296

  
297 297
	/* input validation */
298
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) {
298
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port', 1)) {
299 299
		$input_errors[] = $result;
300 300
	}
301 301

  

Also available in: Unified diff