patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] app/test: fix buffer overflow in table unit tests
@ 2022-04-21 17:35 Vladimir Medvedkin
  2022-04-26 14:03 ` Dumitrescu, Cristian
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Medvedkin @ 2022-04-21 17:35 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu, stable

This patch fixes stack buffer overflow reported by ASAN.

Bugzilla ID: 820
Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test/test_table_tables.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/app/test/test_table_tables.c b/app/test/test_table_tables.c
index d5c5a426bc..010dd5a794 100644
--- a/app/test/test_table_tables.c
+++ b/app/test/test_table_tables.c
@@ -292,10 +292,10 @@ test_table_lpm(void)
 	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
 	void *table;
 	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
-	char entry;
+	uint64_t entry;
 	void *entry_ptr;
 	int key_found;
-	uint32_t entry_size = 1;
+	uint32_t entry_size = sizeof(entry);
 
 	/* Initialize params and create tables */
 	struct rte_table_lpm_params lpm_params = {
@@ -357,7 +357,7 @@ test_table_lpm(void)
 	struct rte_table_lpm_key lpm_key;
 	lpm_key.ip = 0xadadadad;
 
-	table = rte_table_lpm_ops.f_create(&lpm_params, 0, 1);
+	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
 	if (table == NULL)
 		return -9;
 
@@ -458,10 +458,10 @@ test_table_lpm_ipv6(void)
 	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
 	void *table;
 	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
-	char entry;
+	uint64_t entry;
 	void *entry_ptr;
 	int key_found;
-	uint32_t entry_size = 1;
+	uint32_t entry_size = sizeof(entry);
 
 	/* Initialize params and create tables */
 	struct rte_table_lpm_ipv6_params lpm_params = {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-28 10:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 17:35 [PATCH] app/test: fix buffer overflow in table unit tests Vladimir Medvedkin
2022-04-26 14:03 ` Dumitrescu, Cristian
2022-04-28 10:53   ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).