From 6749801b062c7f97fcf2ccebd592579b2a07efc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20=C5=81yszczek?= Date: Thu, 24 Oct 2019 23:20:43 +0200 Subject: [PATCH] rdma/sys.c: fix possible out-of-bound array access MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Stephen Hemminger --- rdma/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdma/sys.c b/rdma/sys.c index cef39081..1a434a25 100644 --- a/rdma/sys.c +++ b/rdma/sys.c @@ -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"; -- 2.39.5