For large strings, we were incorrectly copying uninitialised data to the
output buffer.
Restore previous code.

Fixes: a515b7204e28 ("telemetry: remove VLA in JSON string formatter")

Signed-off-by: David Marchand <david.march...@redhat.com>
---
 lib/telemetry/telemetry_json.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index 7999535848..7a246deacb 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -153,7 +153,7 @@ __json_format_str(char *buf, const int len, const char 
*prefix, const char *str,
 
        ret = __json_format_str_to_buf(tmp, len, prefix, str, suffix);
        if (ret > 0)
-               strcpy(buf, saved);
+               strcpy(buf, tmp);
 
        free(tmp);
        return ret;
-- 
2.40.1

Reply via email to