From: Li Tian <94442129+litian1992@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:43:41 +0000 (+0800) Subject: ukify: rstrip and escape binary null characters from 'inspect' output (#38607) X-Git-Tag: v258-rc3~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=776991a3f349d9c99fd166a0c87fcd2bc1bf92a5;p=thirdparty%2Fsystemd.git ukify: rstrip and escape binary null characters from 'inspect' output (#38607) 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 --- diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py index a09ea09f9ed..2016173855e 100755 --- a/src/ukify/ukify.py +++ b/src/ukify/ukify.py @@ -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)'