From: Julien Cretin Date: Mon, 9 Mar 2015 13:21:09 +0000 (+0100) Subject: app/testpmd: fix potential out of bounds read X-Git-Tag: spdx-start~9390 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=12a8e30fd73dbb6c238a585c995eca5e2c58e24f;p=dpdk.git 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 --- 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; }