From fd43b50113a84608a690acdeeb7fdd8c38be48b8 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Wed, 28 Oct 2020 22:02:48 +0100 Subject: [PATCH] trace: fix metadata dump The ctf metadata is written to the metadata file without any check for length, so this string must be null terminated. Fixes: f1a099f5b1f1 ("trace: create CTF TDSL metadata in memory") Signed-off-by: David Marchand Acked-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace_ctf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index ac1f64d04b..22615c4e73 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -37,11 +37,12 @@ meta_copy(char **meta, int *offset, char *str, int rc) if (rc < 0) return rc; - ptr = realloc(ptr, count + rc); + ptr = realloc(ptr, count + rc + 1); if (ptr == NULL) goto free_str; memcpy(RTE_PTR_ADD(ptr, count), str, rc); + ptr[count + rc] = '\0'; count += rc; free(str); -- 2.20.1