iprule: fix segfault (FS#1875)
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 1 Oct 2018 15:52:01 +0000 (17:52 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sun, 7 Oct 2018 13:18:45 +0000 (15:18 +0200)
Fix segfault in generic_interface_cb by checking the
IPRULE_OUT/IPRULE_IN flags before doing the strcmp for the possible
configured out/in interface(s) of the ip rule.
Also don't copy the interface layer3 device as the layer 3 device is
not yet known when IFEV_CREATE event is launched.
The layer3 device will be known when the IFEV_UP event is processed in
rule_out_cb/rule_in_cb.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
iprule.c

index d3f607332bd54c7d3233907c2f3c4f30a039fd47..27f0c8966f40710bae6a13887d245455a16bc093 100644 (file)
--- a/iprule.c
+++ b/iprule.c
@@ -180,15 +180,11 @@ static void generic_interface_cb(
                if (rule_ready(rule))
                        continue;
 
-               if (!strcmp(rule->out_iface, iface->name)) {
-                       memcpy(rule->out_dev, iface->l3_dev.dev->ifname, sizeof(rule->out_dev));
+               if ((rule->flags & IPRULE_OUT) && !strcmp(rule->out_iface, iface->name))
                        interface_add_user(&rule->out_iface_user, iface);
-               }
 
-               if (!strcmp(rule->in_iface, iface->name)) {
-                       memcpy(rule->in_dev, iface->l3_dev.dev->ifname, sizeof(rule->in_dev));
+               if ((rule->flags & IPRULE_IN) && !strcmp(rule->in_iface, iface->name))
                        interface_add_user(&rule->in_iface_user, iface);
-               }
        }
 }