From: Cristian Dumitrescu Date: Wed, 7 Apr 2021 10:59:53 +0000 (+0100) Subject: table: fix out of bounds write X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=97005a6665f64f920695b0a64cb35bf7cfbd4c3d;p=dpdk.git table: fix out of bounds write 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 --- diff --git a/lib/librte_table/rte_swx_table_wm.c b/lib/librte_table/rte_swx_table_wm.c index 9924231b34..e260be1062 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; }