redirects: fix segmentation fault
authorAlin Nastac <alin.nastac@gmail.com>
Thu, 7 May 2020 11:14:06 +0000 (13:14 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 3 Jun 2020 17:03:55 +0000 (19:03 +0200)
Fixes 9d7f49df47ad ("redurects: add support to define multiple zones for dnat reflection rules")

Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
redirects.c

index 775fadea86d9cb7168c51d87c49173cbd46884f1..9a827b65a892cb9d8794ecdc3bd0a3189a903c0f 100644 (file)
@@ -716,9 +716,8 @@ expand_redirect(struct fw3_ipt_handle *handle, struct fw3_state *state,
                return;
 
        ext_addrs = fw3_resolve_zone_addresses(redir->_src, &redir->ip_dest);
-
        if (!ext_addrs)
-               goto out;
+               return;
 
        list_for_each_entry(ext_addr, ext_addrs, list)
        {
@@ -741,6 +740,9 @@ expand_redirect(struct fw3_ipt_handle *handle, struct fw3_state *state,
                                continue;
 
                        int_addrs = fw3_resolve_zone_addresses(zone, NULL);
+                       if (!int_addrs)
+                               continue;
+
                        list_for_each_entry(int_addr, int_addrs, list)
                        {
                                if (!fw3_is_family(int_addr, handle->family))
@@ -763,12 +765,12 @@ expand_redirect(struct fw3_ipt_handle *handle, struct fw3_state *state,
                                                         &ref_addr, int_addr, ext_addr, reflection_zone);
                                }
                        }
+
+                       fw3_free_list(int_addrs);
                }
        }
 
-out:
        fw3_free_list(ext_addrs);
-       fw3_free_list(int_addrs);
 }
 
 void