]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
Fix NULL pointer reference when using basic match
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Fri, 30 Jul 2010 01:03:35 +0000 (18:03 -0700)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Fri, 30 Jul 2010 01:03:35 +0000 (18:03 -0700)
If basic match has no tree of matches underneath
then print_ematch would core dump.

tc/m_ematch.c

index 7f79a065a1d76a60c67c18b704a745d26ab0836f..4c3acf82b470a5344c3dadc468363592ad010b31 100644 (file)
@@ -449,12 +449,14 @@ static int print_ematch_list(FILE *fd, struct tcf_ematch_tree_hdr *hdr,
        if (tb == NULL)
                return -1;
 
-       if (parse_rtattr_nested(tb, hdr->nmatches, rta) < 0)
-               goto errout;
+       if (hdr->nmatches > 0) {
+               if (parse_rtattr_nested(tb, hdr->nmatches, rta) < 0)
+                       goto errout;
 
-       fprintf(fd, "\n  ");
-       if (print_ematch_seq(fd, tb, 1, 1) < 0)
-               goto errout;
+               fprintf(fd, "\n  ");
+               if (print_ematch_seq(fd, tb, 1, 1) < 0)
+                       goto errout;
+       }
 
        err = 0;
 errout: