app/testpmd: fix unintentional integer overflow

Message ID 20190424022931.32281-1-tiwei.bie@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix unintentional integer overflow |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Tiwei Bie April 24, 2019, 2:29 a.m. UTC
  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@dpdk.org

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

Comments

Iremonger, Bernard April 24, 2019, 12:41 p.m. UTC | #1
> -----Original Message-----
> From: Bie, Tiwei
> Sent: Wednesday, April 24, 2019 3:30 AM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>;
> dev@dpdk.org
> Cc: stable@dpdk.org
> Subject: [PATCH] app/testpmd: fix unintentional integer overflow
> 
> 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@dpdk.org
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  
Ferruh Yigit April 24, 2019, 5:01 p.m. UTC | #2
On 4/24/2019 1:41 PM, Iremonger, Bernard wrote:
>> -----Original Message-----
>> From: Bie, Tiwei
>> Sent: Wednesday, April 24, 2019 3:30 AM
>> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
>> <jingjing.wu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>;
>> dev@dpdk.org
>> Cc: stable@dpdk.org
>> Subject: [PATCH] app/testpmd: fix unintentional integer overflow
>>
>> 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@dpdk.org
>>
>> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

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",