boot: stop appending NUL to .sdmagic and .sbat sections
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 30 Oct 2024 14:30:53 +0000 (15:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 31 Oct 2024 13:58:12 +0000 (14:58 +0100)
commitd97b8d9d7b615066aa99aa5f08c7ca4876d9502d
tree0db019dcef3688bf3ea99245365d85185dacf594
parent07000101eb9529c2d6b5f5402c9fe643c5f98420
boot: stop appending NUL to .sdmagic and .sbat sections

Those text sections had a trailing NUL byte. It's debatable whether this is a
good idea or not. Correctly written consumers will look at the section size so
they wouldn't need this. Shim doesn't use a trailing NUL, so let's follow suit.

Fixes https://github.com/systemd/systemd/issues/33731.

898e9edc469f87fdb6018128bac29eef0a5fe698 reworked this code, but didn't actually
change the logic. We have always been appending the trailing zero by using a
NUL-terminated string as the section contents. (I checked this with v253.18
from before the elf2efi rework.)

.sdmagic contains a string like "#### LoaderInfo: systemd-boot 257~devel ####",
which changes with each version, so previous versions would compare unequal
anyway, so we don't need to worry about backwards compatibility.
src/boot/efi/boot.c
src/fundamental/macro-fundamental.h