[dpdk-dev,1/5] app/testpmd: fix array bounds checks

Message ID 4bf4692b3d38d6f807855ad16d4223ba06107753.1484046037.git.adrien.mazarguil@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Adrien Mazarguil Jan. 10, 2017, 1:08 p.m. UTC
  This commit addresses several obvious issues reported by Coverity (139596,
139597, 139598 and 139599) with array bounds checks in functions related to
the flow API.

Fixes: 938a184a1870 ("app/testpmd: implement basic support for flow API")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 app/test-pmd/config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9716ce7..e1af064 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -884,7 +884,7 @@  port_flow_new(const struct rte_flow_attr *attr,
 	do {
 		struct rte_flow_item *dst = NULL;
 
-		if ((unsigned int)item->type > RTE_DIM(flow_item) ||
+		if ((unsigned int)item->type >= RTE_DIM(flow_item) ||
 		    !flow_item[item->type].name)
 			goto notsup;
 		if (pf)
@@ -918,7 +918,7 @@  port_flow_new(const struct rte_flow_attr *attr,
 	do {
 		struct rte_flow_action *dst = NULL;
 
-		if ((unsigned int)action->type > RTE_DIM(flow_action) ||
+		if ((unsigned int)action->type >= RTE_DIM(flow_action) ||
 		    !flow_action[action->type].name)
 			goto notsup;
 		if (pf)
@@ -977,7 +977,7 @@  port_flow_complain(struct rte_flow_error *error)
 	char buf[32];
 	int err = rte_errno;
 
-	if ((unsigned int)error->type > RTE_DIM(errstrlist) ||
+	if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
 	    !errstrlist[error->type])
 		errstr = "unknown type";
 	else
@@ -1146,7 +1146,7 @@  port_flow_query(portid_t port_id, uint32_t rule,
 		printf("Flow rule #%u not found\n", rule);
 		return -ENOENT;
 	}
-	if ((unsigned int)action > RTE_DIM(flow_action) ||
+	if ((unsigned int)action >= RTE_DIM(flow_action) ||
 	    !flow_action[action].name)
 		name = "unknown";
 	else