[LEDE-DEV] [PATCH v2 1/9] firewall3: check the return value of fw3_parse_options()

pme.lebleu at gmail.com pme.lebleu at gmail.com
Thu May 4 01:50:56 PDT 2017


From: Pierre Lebleu <pme.lebleu at gmail.com>

The return value of fw3_parse_options() should be checked.

Signed-off-by: Pierre Lebleu <pme.lebleu at gmail.com>
---

Notes:
 v1->v2:
  - do not make the fw3_parse_options() error fatal

 defaults.c |    3 ++-
 forwards.c |    3 ++-
 includes.c |    3 ++-
 ipsets.c   |    3 ++-
 zones.c    |    3 ++-
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/defaults.c b/defaults.c
index 8afbf9a..85a3750 100644
--- a/defaults.c
+++ b/defaults.c
@@ -107,7 +107,8 @@ fw3_load_defaults(struct fw3_state *state, struct uci_package *p)
 			continue;
 		}
 
-		fw3_parse_options(&state->defaults, fw3_flag_opts, s);
+		if(!fw3_parse_options(&state->defaults, fw3_flag_opts, s))
+			warn_elem(e, "has invalid options");
 
 		check_policy(e, &defs->policy_input, "input");
 		check_policy(e, &defs->policy_output, "output");
diff --git a/forwards.c b/forwards.c
index 997c307..9b369f3 100644
--- a/forwards.c
+++ b/forwards.c
@@ -54,7 +54,8 @@ fw3_load_forwards(struct fw3_state *state, struct uci_package *p)
 
 		forward->enabled = true;
 
-		fw3_parse_options(forward, fw3_forward_opts, s);
+		if (!fw3_parse_options(forward, fw3_forward_opts, s))
+			warn_elem(e, "has invalid options");
 
 		if (!forward->enabled)
 		{
diff --git a/includes.c b/includes.c
index a9a75cb..a2b37a3 100644
--- a/includes.c
+++ b/includes.c
@@ -54,7 +54,8 @@ fw3_load_includes(struct fw3_state *state, struct uci_package *p)
 		include->name = e->name;
 		include->enabled = true;
 
-		fw3_parse_options(include, fw3_include_opts, s);
+		if (!fw3_parse_options(include, fw3_include_opts, s))
+			warn_elem(e, "has invalid options");
 
 		if (!include->enabled)
 		{
diff --git a/ipsets.c b/ipsets.c
index 0325944..7a72fd3 100644
--- a/ipsets.c
+++ b/ipsets.c
@@ -239,7 +239,8 @@ fw3_load_ipsets(struct fw3_state *state, struct uci_package *p)
 		if (!ipset)
 			continue;
 
-		fw3_parse_options(ipset, fw3_ipset_opts, s);
+		if (!fw3_parse_options(ipset, fw3_ipset_opts, s))
+			warn_elem(e, "has invalid options");
 
 		if (ipset->external)
 		{
diff --git a/zones.c b/zones.c
index 26f6215..2aa7473 100644
--- a/zones.c
+++ b/zones.c
@@ -171,7 +171,8 @@ fw3_load_zones(struct fw3_state *state, struct uci_package *p)
 		if (!zone)
 			continue;
 
-		fw3_parse_options(zone, fw3_zone_opts, s);
+		if (!fw3_parse_options(zone, fw3_zone_opts, s))
+			warn_elem(e, "has invalid options");
 
 		if (!zone->enabled)
 		{
-- 
1.7.9.5




More information about the Lede-dev mailing list