DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] table: fix out of bounds write
Date: Wed,  7 Apr 2021 11:59:53 +0100
Message-ID: <20210407105953.18113-1-cristian.dumitrescu@intel.com> (raw)

Fix out of bounds write. The allocated string size was incorrect.

Coverity issue: 369670
Fixes: 66440b7b22f2 ("table: add wildcard match table type")

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/librte_table/rte_swx_table_wm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/librte_table/rte_swx_table_wm.c b/lib/librte_table/rte_swx_table_wm.c
index 9924231b3..e260be106 100644
--- a/lib/librte_table/rte_swx_table_wm.c
+++ b/lib/librte_table/rte_swx_table_wm.c
@@ -53,15 +53,14 @@ env_free(void *start, size_t size)
 
 static char *get_unique_name(void)
 {
-	char *name;
-	uint64_t *tsc;
+	uint64_t tsc = rte_get_tsc_cycles();
+	size_t size = sizeof(uint64_t) * 2 + 1;
+	char *name = calloc(1, size);
 
-	name = calloc(7, 1);
 	if (!name)
 		return NULL;
 
-	tsc = (uint64_t *) name;
-	*tsc = rte_get_tsc_cycles();
+	snprintf(name, size, "%016" PRIx64, tsc);
 	return name;
 }
 
-- 
2.17.1


             reply	other threads:[~2021-04-07 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 10:59 Cristian Dumitrescu [this message]
2021-04-19 17:51 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210407105953.18113-1-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git