From 12a8e30fd73dbb6c238a585c995eca5e2c58e24f Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Mon, 9 Mar 2015 14:21:09 +0100 Subject: [PATCH] app/testpmd: fix potential out of bounds read After the last enabled port has been seen, and the last time we evaluate the loop condition, there is an out of bounds read in ports[p].enabled because p is equal to size, which is the length of ports. Signed-off-by: Julien Cretin Acked-by: Thomas Monjalon --- app/test-pmd/testpmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4828354bf4..30577919bc 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -332,7 +332,7 @@ find_next_port(portid_t p, struct rte_port *ports, int size) if (ports == NULL) rte_exit(-EINVAL, "failed to find a next port id\n"); - while ((ports[p].enabled == 0) && (p < size)) + while ((p < size) && (ports[p].enabled == 0)) p++; return p; } -- 2.20.1