]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc/q_netem: Don't dereference possibly NULL pointer
authorPhil Sutter <phil@nwl.cc>
Thu, 24 Aug 2017 09:46:32 +0000 (11:46 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 24 Aug 2017 21:49:44 +0000 (14:49 -0700)
Assuming 'opt' might be NULL, move the call to RTA_PAYLOAD to after the
check since it dereferences its parameter.

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

index 0975ae111de97b749d937413c6483c51e12fdf17..5a9e747411e852031d7029afb1ede07f99d46923 100644 (file)
@@ -538,7 +538,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
        int *ecn = NULL;
        struct tc_netem_qopt qopt;
        const struct tc_netem_rate *rate = NULL;
-       int len = RTA_PAYLOAD(opt) - sizeof(qopt);
+       int len;
        __u64 rate64 = 0;
 
        SPRINT_BUF(b1);
@@ -546,6 +546,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
        if (opt == NULL)
                return 0;
 
+       len = RTA_PAYLOAD(opt) - sizeof(qopt);
        if (len < 0) {
                fprintf(stderr, "options size error\n");
                return -1;