From: Zbigniew Jędrzejewski-Szmek Date: Tue, 19 Aug 2025 09:11:28 +0000 (+0200) Subject: ukify: stop appending NUL to merged .sbat section X-Git-Tag: v258-rc3~9^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F38621%2Fhead;p=thirdparty%2Fsystemd.git ukify: stop appending NUL to merged .sbat section Our tools will strip trailing NULs, so this is not causing harm, except for the corner case when the .sbat section is exactly of the maximum size and now it wouldn't fit because we're one byte short. But it also is not needed. Sections have an encoded size of the data and the reader must use that and must be prepared to handle a text section that does not end in NUL. Appending of the NUL was added in c3f7501c4d014482b17988d5aed1d88127a50b6e, without any discussion of this change. Since we didn't insert the NUL before, the tools must have been prepared to work without it. I think it's better to keep the code clean and not do this unnecessary step. --- diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py index e3c427166d3..c034befd85f 100755 --- a/src/ukify/ukify.py +++ b/src/ukify/ukify.py @@ -1150,10 +1150,12 @@ def merge_sbat(input_pe: list[Path], input_text: list[str]) -> str: continue sbat += split[1:] - return ( - 'sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md\n' - + '\n'.join(sbat) - + '\n\x00' + return '\n'.join( + ( + 'sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md', + *sbat, + '', # an empty line so that we end up with a newline at the end + ) )