[dpdk-stable] [PATCH] app/testpmd: fix unintentional integer overflow

Tiwei Bie tiwei.bie at intel.com
Wed Apr 24 04:29:31 CEST 2019


Fix the potential overflow in expression 1 << begin by using 1ULL.

Coverity issue: 279437, 279445
Fixes: c73a9071877a ("app/testpmd: add commands to test new offload API")
Cc: stable at dpdk.org

Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
---
 app/test-pmd/cmdline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 5a10c5f38..03926f913 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -17739,7 +17739,7 @@ print_rx_offloads(uint64_t offloads)
 	begin = __builtin_ctzll(offloads);
 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
 
-	single_offload = 1 << begin;
+	single_offload = 1ULL << begin;
 	for (bit = begin; bit < end; bit++) {
 		if (offloads & single_offload)
 			printf(" %s",
@@ -18133,7 +18133,7 @@ print_tx_offloads(uint64_t offloads)
 	begin = __builtin_ctzll(offloads);
 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
 
-	single_offload = 1 << begin;
+	single_offload = 1ULL << begin;
 	for (bit = begin; bit < end; bit++) {
 		if (offloads & single_offload)
 			printf(" %s",
-- 
2.17.1



More information about the stable mailing list