From ee45041da19b9db3352460f917a417a36db71782 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 19 Aug 2025 11:11:28 +0200 Subject: [PATCH] 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. --- src/ukify/ukify.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 + ) ) -- 2.47.3