Ensure that the value passed to ipfw pipes is always an integer, no matter the source. Fixes #8097

This commit is contained in:
jim-p 2017-11-15 09:01:22 -05:00
parent 947394d291
commit 7c4e07c625
2 changed files with 10 additions and 6 deletions

View File

@ -2103,8 +2103,9 @@ function captiveportal_reapply_attributes($cpentry, $attributes) {
} else {
$dwfaultbw_up = $dwfaultbw_down = 0;
}
$bw_up = !empty($attributes['bw_up']) ? round(intval($attributes['bw_up'])/1000, 2) : $dwfaultbw_up;
$bw_down = !empty($attributes['bw_down']) ? round(intval($attributes['bw_down'])/1000, 2) : $dwfaultbw_down;
/* pipe throughputs must always be an integer, enforce that restriction again here. */
$bw_up = round(!empty($attributes['bw_up']) ? intval($attributes['bw_up'])/1000 : $dwfaultbw_up, 0);
$bw_down = round(!empty($attributes['bw_down']) ? intval($attributes['bw_down'])/1000 : $dwfaultbw_down, 0);
$bw_up_pipeno = $cpentry[1];
$bw_down_pipeno = $cpentry[1]+1;
@ -2249,8 +2250,9 @@ function portal_allow($clientip, $clientmac, $username, $password = null, $attri
} else {
$dwfaultbw_up = $dwfaultbw_down = 0;
}
$bw_up = !empty($attributes['bw_up']) ? round(intval($attributes['bw_up'])/1000, 2) : $dwfaultbw_up;
$bw_down = !empty($attributes['bw_down']) ? round(intval($attributes['bw_down'])/1000, 2) : $dwfaultbw_down;
/* pipe throughputs must always be an integer, enforce that restriction again here. */
$bw_up = round(!empty($attributes['bw_up']) ? intval($attributes['bw_up'])/1000 : $dwfaultbw_up, 0);
$bw_down = round(!empty($attributes['bw_down']) ? intval($attributes['bw_down'])/1000 : $dwfaultbw_down, 0);
if ($passthrumac) {
$mac = array();

View File

@ -3613,7 +3613,8 @@ class dnpipe_class extends dummynet_class {
foreach ($config['schedules']['schedule'] as $schedule) {
if ($bw['bwsched'] == $schedule['name']) {
if (filter_get_time_based_rule_status($schedule)) {
$pfq_rule .= " bw ".trim($bw['bw']).$bw['bwscale'];
/* pipe throughputs must always be an integer, enforce that restriction again here. */
$pfq_rule .= " bw ".round(trim($bw['bw']),0).$bw['bwscale'];
if (is_numeric($bw['burst']) && ($bw['burst'] > 0)) {
$pfq_rule .= " burst ".trim($bw['burst']);
}
@ -3628,7 +3629,8 @@ class dnpipe_class extends dummynet_class {
break;
}
} else {
$pfq_rule .= " bw ".trim($bw['bw']).$bw['bwscale'];
/* pipe throughputs must always be an integer, enforce that restriction again here. */
$pfq_rule .= " bw ".round(trim($bw['bw']), 0).$bw['bwscale'];
if (is_numeric($bw['burst']) && ($bw['burst'] > 0)) {
$pfq_rule .= " burst ".trim($bw['burst']);
}