Skip to contentSkip to conversation

telemetry: fix JSON string formatter

PATCH Applied David Marchand 3 participants 3 messages May 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 telemetry: fix JSON string formatter

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")
---
 lib/telemetry/telemetry_json.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/telemetry/telemetry_json.h +1 -1
index 7999535848..7a246deacb 100644
@@ -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;
Signature · 1 line
2.40.1
#2 lore raw

25/05/2023 10:30, Bruce Richardson:

Quoted 10 lines · David Marchand
Quoted 8 lines

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")

---

Applied, thanks (and sorry for merging the commit triggering CI failures).