From: Yong Wang Date: Tue, 12 Sep 2017 12:44:00 +0000 (-0400) Subject: net/igb: fix memcpy length X-Git-Tag: spdx-start~1945 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=671f8776871d2e46c0619c743a82b2f6f6ce58ec;p=dpdk.git net/igb: fix memcpy length The size of "flex_filter.filter_info.mask" and "filter->mask" are 16 bytes, but the length of memcpy--"RTE_ALIGN(filter->len, sizeof(char)) / sizeof(char)" may reach 128 bytes which may cause array access out of bound. Fix it by replacing "sizeof(char)" by "CHAR_BIT". Fixes: 231d43909a31 ("igb: migrate flex filter to new API") Cc: stable@dpdk.org Signed-off-by: Yong Wang Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index e4f7a9faf1..8078a1ec5d 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -4094,7 +4094,7 @@ eth_igb_get_flex_filter(struct rte_eth_dev *dev, flex_filter.filter_info.priority = filter->priority; memcpy(flex_filter.filter_info.dwords, filter->bytes, filter->len); memcpy(flex_filter.filter_info.mask, filter->mask, - RTE_ALIGN(filter->len, sizeof(char)) / sizeof(char)); + RTE_ALIGN(filter->len, CHAR_BIT) / CHAR_BIT); it = eth_igb_flex_filter_lookup(&filter_info->flex_list, &flex_filter.filter_info);