[LEDE-DEV] [PATCH 2/7] firewall3: do not use a wrong pointer in the warn() function

Pierre Lebleu pme.lebleu at gmail.com
Thu Apr 20 09:05:37 PDT 2017


In the function fw3_load_rules(), warm_elem() used a pointer
to an UCI section which was not valid anymore.

Signed-off-by: Pierre Lebleu <pme.lebleu at gmail.com>
---
 rules.c |   31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/rules.c b/rules.c
index 8f232d3..a1b154d 100644
--- a/rules.c
+++ b/rules.c
@@ -159,41 +159,41 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p,
 
 		if (rule->src.invert || rule->dest.invert)
 		{
-			warn_elem(e, "must not have inverted 'src' or 'dest' options");
+			warn("%s must not have inverted 'src' or 'dest' options", rule->name);
 			fw3_free_rule(rule);
 			continue;
 		}
 		else if (rule->src.set && !rule->src.any &&
 		         !(rule->_src = fw3_lookup_zone(state, rule->src.name)))
 		{
-			warn_elem(e, "refers to not existing zone '%s'", rule->src.name);
+			warn("%s refers to not existing zone '%s'", rule->name, rule->src.name);
 			fw3_free_rule(rule);
 			continue;
 		}
 		else if (rule->dest.set && !rule->dest.any &&
 		         !(rule->_dest = fw3_lookup_zone(state, rule->dest.name)))
 		{
-			warn_elem(e, "refers to not existing zone '%s'", rule->dest.name);
+			warn("%s refers to not existing zone '%s'", rule->name, rule->dest.name);
 			fw3_free_rule(rule);
 			continue;
 		}
 		else if (rule->ipset.set && state->disable_ipsets)
 		{
-			warn_elem(e, "skipped due to disabled ipset support");
+			warn("%s skipped due to disabled ipset support", rule->name);
 			fw3_free_rule(rule);
 			continue;
 		}
 		else if (rule->ipset.set &&
 		         !(rule->ipset.ptr = fw3_lookup_ipset(state, rule->ipset.name)))
 		{
-			warn_elem(e, "refers to unknown ipset '%s'", rule->ipset.name);
+			warn("%s refers to unknown ipset '%s'", rule->name, rule->ipset.name);
 			fw3_free_rule(rule);
 			continue;
 		}
 
 		if (!rule->_src && rule->target == FW3_FLAG_NOTRACK)
 		{
-			warn_elem(e, "is set to target NOTRACK but has no source assigned");
+			warn("%s is set to target NOTRACK but has no source assigned", rule->name);
 			fw3_free_rule(rule);
 			continue;
 		}
@@ -201,46 +201,47 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p,
 		if (!rule->set_mark.set && !rule->set_xmark.set &&
 		    rule->target == FW3_FLAG_MARK)
 		{
-			warn_elem(e, "is set to target MARK but specifies neither "
-			             "'set_mark' nor 'set_xmark' option");
+			warn("%s is set to target MARK but specifies neither "
+			             "'set_mark' nor 'set_xmark' option", rule->name);
 			fw3_free_rule(rule);
 			continue;
 		}
 
 		if (rule->_dest && rule->target == FW3_FLAG_MARK)
 		{
-			warn_elem(e, "must not specify 'dest' for MARK target");
+			warn("%s must not specify 'dest' for MARK target", rule->name);
 			fw3_free_rule(rule);
 			continue;
 		}
 
 		if (rule->set_mark.invert || rule->set_xmark.invert)
 		{
-			warn_elem(e, "must not have inverted 'set_mark' or 'set_xmark'");
+			warn("%s must not have inverted 'set_mark' or 'set_xmark'", rule->name);
 			fw3_free_rule(rule);
 			continue;
 		}
 
 		if (!rule->_src && !rule->_dest && !rule->src.any && !rule->dest.any)
 		{
-			warn_elem(e, "has neither a source nor a destination zone assigned "
-			             "- assuming an output rule");
+			warn("%s has neither a source nor a destination zone assigned "
+			             "- assuming an output rule", rule->name);
 		}
 
 		if (list_empty(&rule->proto))
 		{
-			warn_elem(e, "does not specify a protocol, assuming TCP+UDP");
+			warn("%s does not specify a protocol, assuming TCP+UDP", rule->name);
 			fw3_parse_protocol(&rule->proto, "tcpudp", true);
 		}
 
 		if (rule->target == FW3_FLAG_UNSPEC)
 		{
-			warn_elem(e, "has no target specified, defaulting to REJECT");
+			warn("%s has no target specified, defaulting to REJECT", rule->name);
 			rule->target = FW3_FLAG_REJECT;
 		}
 		else if (rule->target > FW3_FLAG_MARK)
 		{
-			warn_elem(e, "has invalid target specified, defaulting to REJECT");
+			warn("%s has invalid target specified, defaulting to REJECT",
+					rule->name);
 			rule->target = FW3_FLAG_REJECT;
 		}
 
-- 
1.7.9.5




More information about the Lede-dev mailing list