]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: fix compiler warnings in ip6 pedit
authorStephen Hemminger <stephen@networkplumber.org>
Sun, 29 Nov 2020 17:40:49 +0000 (09:40 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 30 Nov 2020 00:20:23 +0000 (16:20 -0800)
Gcc-10 complains about referencing a zero size array.
This occurs because the array of keys is actually in the following
structure which is part of the overall selector.

The original code was safe, but better to just use the key
array directly.

Fixes: 2d9a8dc439ee ("tc: p_ip6: Support pedit of IPv6 dsfield")
Cc: petrm@mellanox.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/p_ip6.c

index 71660c610c827b1a2c25370b1895639b5e12ed21..83a6ae8183a7fe5594a3490289a5f755dba71425 100644 (file)
@@ -82,7 +82,7 @@ parse_ip6(int *argc_p, char ***argv_p,
                /* Shift the field by 4 bits on success. */
                if (!res) {
                        int nkeys = sel->sel.nkeys;
-                       struct tc_pedit_key *key = &sel->sel.keys[nkeys - 1];
+                       struct tc_pedit_key *key = &sel->keys[nkeys - 1];
 
                        key->mask = htonl(ntohl(key->mask) << 4 | 0xf);
                        key->val = htonl(ntohl(key->val) << 4);