[dpdk-dev] app/test: fix memory_autotest integer overflow/wraparound

Message ID 1447774756-107404-1-git-send-email-sergio.gonzalez.monroy@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Sergio Gonzalez Monroy Nov. 17, 2015, 3:39 p.m. UTC
  memory_autotest loops infinitely when at least one the memsegs
is bigger than 4GB.

The issue is the result of an integer overflow/wraparound of
the offset variable.

Fix it by using the correct type (size_t).

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 app/test/test_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

De Lara Guarch, Pablo Dec. 2, 2015, 11:49 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Sergio Gonzalez
> Monroy
> Sent: Tuesday, November 17, 2015 3:39 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] app/test: fix memory_autotest integer
> overflow/wraparound
> 
> memory_autotest loops infinitely when at least one the memsegs
> is bigger than 4GB.
> 
> The issue is the result of an integer overflow/wraparound of
> the offset variable.
> 
> Fix it by using the correct type (size_t).
> 
> Signed-off-by: Sergio Gonzalez Monroy
> <sergio.gonzalez.monroy@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
  
Thomas Monjalon Dec. 7, 2015, 2:46 a.m. UTC | #2
> > memory_autotest loops infinitely when at least one the memsegs
> > is bigger than 4GB.
> > 
> > The issue is the result of an integer overflow/wraparound of
> > the offset variable.
> > 
> > Fix it by using the correct type (size_t).
> > 
> > Signed-off-by: Sergio Gonzalez Monroy
> > <sergio.gonzalez.monroy@intel.com>
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied, thanks
  

Patch

diff --git a/app/test/test_memory.c b/app/test/test_memory.c
index 02ef3cf..6816385 100644
--- a/app/test/test_memory.c
+++ b/app/test/test_memory.c
@@ -55,7 +55,8 @@  static int
 test_memory(void)
 {
 	uint64_t s;
-	unsigned i, j;
+	unsigned i;
+	size_t j;
 	const struct rte_memseg *mem;
 
 	/*