]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma/sys.c: fix possible out-of-bound array access
authorMichał Łyszczek <michal.lyszczek@bofc.pl>
Thu, 24 Oct 2019 21:20:43 +0000 (23:20 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 28 Oct 2019 17:33:27 +0000 (10:33 -0700)
netns_modes_str[] array has 2 elements, when netns_mode is 2,
condition (2 <= 2) will be true and `mode_str = netns_modes_str[2]'
will be executed, which will result in out-of-bound read.

Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
rdma/sys.c

index cef39081872c61071d7baa61798f4491df672dc8..1a434a25b7af2bb7d933767d2588fa1e7b5af066 100644 (file)
@@ -31,7 +31,7 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
                netns_mode =
                        mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_NETNS_MODE]);
 
-               if (netns_mode <= ARRAY_SIZE(netns_modes_str))
+               if (netns_mode < ARRAY_SIZE(netns_modes_str))
                        mode_str = netns_modes_str[netns_mode];
                else
                        mode_str = "unknown";