redirects: fix possible null pointer access
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 13 Jan 2015 11:46:37 +0000 (12:46 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 13 Jan 2015 11:46:37 +0000 (12:46 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
redirects.c

index a30c5406b9fd47f24a2e965c01ce63d2824804a1..50ed44d88d5a82d624dafcc4145c37c4db3c4f0e 100644 (file)
@@ -312,20 +312,20 @@ fw3_load_redirects(struct fw3_state *state, struct uci_package *p)
                                set(redir->_src->flags, FW3_FAMILY_V4, redir->target);
                                redir->_src->conntrack = true;
                                valid = true;
-                       }
 
-                       if (!check_local(e, redir, state) && !redir->dest.set &&
-                           resolve_dest(e, redir, state))
-                       {
-                               warn_elem(e, "does not specify a destination, assuming '%s'",
-                                         redir->dest.name);
-                       }
+                               if (!check_local(e, redir, state) && !redir->dest.set &&
+                                   resolve_dest(e, redir, state))
+                               {
+                                       warn_elem(e, "does not specify a destination, assuming '%s'",
+                                                 redir->dest.name);
+                               }
 
-                       if (redir->reflection && redir->_dest && redir->_src->masq)
-                       {
-                               set(redir->_dest->flags, FW3_FAMILY_V4, FW3_FLAG_ACCEPT);
-                               set(redir->_dest->flags, FW3_FAMILY_V4, FW3_FLAG_DNAT);
-                               set(redir->_dest->flags, FW3_FAMILY_V4, FW3_FLAG_SNAT);
+                               if (redir->reflection && redir->_dest && redir->_src->masq)
+                               {
+                                       set(redir->_dest->flags, FW3_FAMILY_V4, FW3_FLAG_ACCEPT);
+                                       set(redir->_dest->flags, FW3_FAMILY_V4, FW3_FLAG_DNAT);
+                                       set(redir->_dest->flags, FW3_FAMILY_V4, FW3_FLAG_SNAT);
+                               }
                        }
                }
                else