Skip to contentSkip to conversation

app/testpmd: fix integer overflow

PATCH Applied Jasvinder Singh 2 participants 3 messages Oct 19, 2017 – Oct 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: fix integer overflow

Fixed integer overflow by casting link_params.link_speed to uint64_t type.

CID 195016 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Fixes 5b590fbe09b6 ("app/testpmd: add traffic management forwarding mode")
---
 app/test-pmd/tm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/tm.c +1 -1
index da1adda..dd837cb 100644
@@ -335,7 +335,7 @@ set_tm_hiearchy_nodes_shaper_rate(portid_t port_id, struct tm_hierarchy *h)
 	memset(&link_params, 0, sizeof(link_params));
 
 	rte_eth_link_get(port_id, &link_params);
-	tm_port_rate = link_params.link_speed * BYTES_IN_MBPS;
+	tm_port_rate = (uint64_t)link_params.link_speed * BYTES_IN_MBPS;
 
 	if (tm_port_rate > UINT32_MAX)
 		tm_port_rate = UINT32_MAX;
Signature · 1 line
2.9.3