]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze: C escape weird chars in SMBIOS fields
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Dec 2024 11:13:43 +0000 (12:13 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 Dec 2024 17:13:18 +0000 (18:13 +0100)
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

index e89112f23f19f637f0254778cbe46f410dfb9561..22f7b6d603589758a950ef5f89f86d7b3b7d9cff 100644 (file)
@@ -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();
                         }