From: Lennart Poettering Date: Fri, 20 Dec 2024 11:13:43 +0000 (+0100) Subject: analyze: C escape weird chars in SMBIOS fields X-Git-Tag: v258-rc1~1796^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b99f3ba5a11a442635fb4cb3397dd7ee8d87af6;p=thirdparty%2Fsystemd.git 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. --- 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(); }