]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: m_xt: Prevent segfault with standard targets
authorPhil Sutter <phil@nwl.cc>
Fri, 10 Jun 2016 11:42:00 +0000 (13:42 +0200)
committerStephen Hemminger <shemming@brocade.com>
Tue, 14 Jun 2016 21:35:56 +0000 (14:35 -0700)
Iptables standard targets like DROP or REJECT don't implement the print
callback in libxtables. Hence the following command would segfault:

| tc filter add dev d0 parent ffff: u32 match u32 0 0 action xt -j DROP

With this patch standard targets still can't be used (and are not really
useful anyway), but at least it doesn't crash anymore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
tc/m_xt.c

index c3f866df14749ff61a4a2e8b963f943028c14951..62ec6d7f18e73205d0268e97113a4df75d1475bc 100644 (file)
--- a/tc/m_xt.c
+++ b/tc/m_xt.c
@@ -250,8 +250,12 @@ static int parse_ipt(struct action_util *a, int *argc_p,
        fprintf(stdout, "tablename: %s hook: %s\n ", tname, ipthooks[hook]);
        fprintf(stdout, "\ttarget: ");
 
-       if (m)
-               m->print(NULL, m->t, 0);
+       if (m) {
+               if (m->print)
+                       m->print(NULL, m->t, 0);
+               else
+                       printf("%s ", m->name);
+       }
        fprintf(stdout, " index %d\n", index);
 
        if (strlen(tname) > 16) {