diff mbox

[PATCHv2,1/2] validation: queue: use signed vars to avoid out of bounds references

Message ID 1467201583-4892-2-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer June 29, 2016, 11:59 a.m. UTC
The variables i and num_queues must be int32_t rather than uint32_t to
avoid a potential loop overrun in the event that the initial
odp_queue_create() for i = 0 fails. In this case num_queues is set to -1,
but since it is uint32_t it is interpreted as a very large positive number.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 test/validation/queue/queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
index be9c0dc..d88e74b 100644
--- a/test/validation/queue/queue.c
+++ b/test/validation/queue/queue.c
@@ -56,7 +56,7 @@  void queue_test_capa(void)
 	odp_queue_param_t qparams;
 	char name[ODP_QUEUE_NAME_LEN];
 	odp_queue_t queue[MAX_QUEUES];
-	uint32_t num_queues, i;
+	int32_t num_queues, i;
 
 	memset(&capa, 0, sizeof(odp_queue_capability_t));
 	CU_ASSERT(odp_queue_capability(&capa) == 0);