From 6b99f3ba5a11a442635fb4cb3397dd7ee8d87af6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 20 Dec 2024 12:13:43 +0100 Subject: [PATCH] analyze: C escape weird chars in SMBIOS fields just in case, let's not write garbled crap to the TTY but escape and potential weird chars before output. --- src/analyze/analyze-chid.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/analyze/analyze-chid.c b/src/analyze/analyze-chid.c index e89112f23f1..22f7b6d6035 100644 --- a/src/analyze/analyze-chid.c +++ b/src/analyze/analyze-chid.c @@ -4,6 +4,7 @@ #include "analyze-chid.h" #include "chid-fundamental.h" #include "efi-api.h" +#include "escape.h" #include "fd-util.h" #include "fileio.h" #include "format-table.h" @@ -209,7 +210,13 @@ int verb_chid(int argc, char *argv[], void *userdata) { _cleanup_free_ char *c = NULL; if (smbios_fields[f]) { - c = utf16_to_utf8(smbios_fields[f], SIZE_MAX); + _cleanup_free_ char *u = NULL; + + u = utf16_to_utf8(smbios_fields[f], SIZE_MAX); + if (!u) + return log_oom(); + + c = cescape(u); if (!c) return log_oom(); }