Skip to content

Commit 6749801

Browse files
mlyszczekshemminger
authored andcommitted
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>
1 parent 085ab19 commit 6749801

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rdma/sys.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data)
3131
netns_mode =
3232
mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_NETNS_MODE]);
3333

34-
if (netns_mode <= ARRAY_SIZE(netns_modes_str))
34+
if (netns_mode < ARRAY_SIZE(netns_modes_str))
3535
mode_str = netns_modes_str[netns_mode];
3636
else
3737
mode_str = "unknown";

0 commit comments

Comments
 (0)