Skip to content

Commit

Permalink
Fix toggleNATrule() always returning 'enabled' for a single rule
Browse files Browse the repository at this point in the history
When toggleNATrule() was modified to accept a list of NAT rules, the default
case for a single 'id' in the postdata was broken by building a rule map of {id
=> id}, and attempting later to index that map with id 0. If the rule being
toggled isn't rule 0, this fails. The code is corrected to simply build an array
of { id } that is zero-indexed.
  • Loading branch information
Reid Linnemann committed Jan 10, 2025
1 parent 5d3bf10 commit 837c16f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/usr/local/pfSense/include/www/firewall_nat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ function saveNATrule($post, $id, $json = false) {
function toggleNATrule($post, $json = false) {
// Check for single rule
if (!(is_array($post['rule']) && count($post['rule']))) {
$post['rule'] = array( $post['id'] => $post['id'] );
$post['rule'] = [ $post['id'] ];
}

foreach ($post['rule'] as $rulei) {
Expand Down

0 comments on commit 837c16f

Please sign in to comment.