Validate channel w/ RASPI_5GHZ_MAX_CHANNEL, addresses #450

This commit is contained in:
billz 2020-10-25 07:48:41 +00:00
parent 8686406ef1
commit b095073043

View file

@ -118,19 +118,19 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
error_log("Attempting to set hostapd config with wpa='".$_POST['wpa']."', wpa_pairwise='".$_POST['wpa_pairwise']."' and hw_mode='".$_POST['hw_mode']."'"); // FIXME: log injection
return false;
}
// Validate input
$good_input = true;
if (!filter_var($_POST['channel'], FILTER_VALIDATE_INT)) {
error_log("Attempting to set channel to invalid number.");
return false;
$status->addMessage('Attempting to set channel to invalid number.', 'danger');
$good_input = false;
}
if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > 48) {
error_log("Attempting to set channel to '".$_POST['channel']."'");
return false;
if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > RASPI_5GHZ_MAX_CHANNEL) {
$status->addMessage('Attempting to set channel outside of permitted range', 'danger');
$good_input = false;
}
$good_input = true;
// Check for Bridged AP mode checkbox
$bridgedEnable = 0;
if ($arrHostapdConf['BridgedEnable'] == 0) {