rdma/sys.c: fix possible out-of-bound array access

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>
This commit is contained in:
Michał Łyszczek 2019-10-24 23:20:43 +02:00 committed by Stephen Hemminger
parent 085ab19bc3
commit 6749801b06
1 changed files with 1 additions and 1 deletions

View 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";