firewall: Avoid creating a rule that permits all traffic on invalid source

Message ID 20230117134144.2763140-1-michael.tremer@ipfire.org
State Accepted
Commit 9c02f36e21ed477a824a1d6f73206e6ef40636b1
Headers
Series firewall: Avoid creating a rule that permits all traffic on invalid source |

Commit Message

Michael Tremer Jan. 17, 2023, 1:41 p.m. UTC
  The firewall engine generated rules that did not have any traffic
selectors due to an improperly initialized variable in the source.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 config/firewall/rules.pl | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Peter Müller Jan. 18, 2023, 11:26 p.m. UTC | #1
Acked-by: Peter Müller <peter.mueller@ipfire.org>

> The firewall engine generated rules that did not have any traffic
> selectors due to an improperly initialized variable in the source.
> 
> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
>  config/firewall/rules.pl | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
> index 30ad20df1..1b628df16 100644
> --- a/config/firewall/rules.pl
> +++ b/config/firewall/rules.pl
> @@ -401,6 +401,9 @@ sub buildrules {
>  					$source = "";
>  				}
>  
> +				# Make sure that $source is properly defined
> +				next unless (defined $source);
> +
>  				my $source_intf = @$src[1];
>  
>  				foreach my $dst (@destinations) {
  

Patch

diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
index 30ad20df1..1b628df16 100644
--- a/config/firewall/rules.pl
+++ b/config/firewall/rules.pl
@@ -401,6 +401,9 @@  sub buildrules {
 					$source = "";
 				}
 
+				# Make sure that $source is properly defined
+				next unless (defined $source);
+
 				my $source_intf = @$src[1];
 
 				foreach my $dst (@destinations) {