firewall3: check the return value of fw3_parse_options()
authorPierre Lebleu <pme.lebleu@gmail.com>
Thu, 4 May 2017 08:50:56 +0000 (10:50 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 9 May 2017 21:54:15 +0000 (23:54 +0200)
The return value of fw3_parse_options() should be checked.

Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
defaults.c
forwards.c
includes.c
ipsets.c
zones.c

index 8afbf9acf8323071c7ba4f59666987eb76b1a9d7..85a3750a52c6e6bcfc9ee12b424d44ac946f8041 100644 (file)
@@ -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");
index 997c30712614373ae3b8f9fd94b02cdc2f8ebc2a..9b369f386979d1acb5f0dc74b8bda1c474ae3e90 100644 (file)
@@ -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)
                {
index a9a75cbdaedd5b7aa8aab01d264b4faa4720af51..a2b37a32e09b09bad717783171c04a6807910871 100644 (file)
@@ -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)
                {
index 03259444b564c30e582189836d1fe1e36154bbb5..7a72fd35a378941304c8308f75f65b91ae6fc8d3 100644 (file)
--- 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 26f6215b22b77a793aa73061b29f2abbbaf17cc9..2aa74738ebcddb23263bfb8f172b975030f3b7e4 100644 (file)
--- 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)
                {