]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: rstrip and escape binary null characters from 'inspect' output (#38607)
authorLi Tian <94442129+litian1992@users.noreply.github.com>
Mon, 18 Aug 2025 21:43:41 +0000 (05:43 +0800)
committerGitHub <noreply@github.com>
Mon, 18 Aug 2025 21:43:41 +0000 (22:43 +0100)
SBAT section of UKI may contain \u000 null characters. Rstrip them, and if there's anything left in the middle,
escape them so they are displayed as text.

Fixes #38606

src/ukify/ukify.py

index a09ea09f9ed9537beafcb90c963b9c1993418428..2016173855e56911a007e02d9aeaa8251b49fe05 100755 (executable)
@@ -1695,7 +1695,7 @@ def inspect_section(
 
     if ttype == 'text':
         try:
-            struct['text'] = data.decode()
+            struct['text'] = data.rstrip(b'\0').replace(b'\0', b'\\0').decode()
         except UnicodeDecodeError as e:
             print(f'Section {name!r} is not valid text: {e}', file=sys.stderr)
             struct['text'] = '(not valid UTF-8)'