From: Zbigniew Jędrzejewski-Szmek Date: Fri, 6 May 2022 15:36:47 +0000 (+0200) Subject: shared/bootspec: avoid crashing on config without a value X-Git-Tag: v251-rc3~39^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b6bd2562ebb01b48cdb55a970d9daa1799b59876;p=thirdparty%2Fsystemd.git shared/bootspec: avoid crashing on config without a value --- diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 50875021d42..bc0994f9bd1 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -127,6 +127,13 @@ static int boot_entry_load_type1( continue; } + if (isempty(p)) { + /* Some fields can reasonably have an empty value. In other cases warn. */ + if (!STR_IN_SET(field, "options", "devicetree-overlay")) + log_warning("%s:%u: Field %s without value", tmp.path, line, field); + continue; + } + if (streq(field, "title")) r = free_and_strdup(&tmp.title, p); else if (streq(field, "sort-key")) diff --git a/test/fuzz/fuzz-bootspec/crash-empty-value b/test/fuzz/fuzz-bootspec/crash-empty-value new file mode 100644 index 00000000000..5436e44987b --- /dev/null +++ b/test/fuzz/fuzz-bootspec/crash-empty-value @@ -0,0 +1 @@ +{"config": "timeout 3\nconsole-mode 2\n# default 08a5690afeedfeedaaac0a5d2e3cf6b0-*\n# default auto-reboot-to-firmware-set*up\n", "entries": [["08a5690afeedfeedaaac0a5d2e3cf6b0-5.15.14-200.fc35.x86_64.conf", "title Fedora Linux 35 (Workstation Edition)\nversio' 5.15.14-200.fc35.x86_64\nmachine-id 08a5690afeedfeedaaac0a5d2e3cf6b0\noptions root=/dev/mapper/fedora_krowka-root rw rd.lvm.lv=fedora_krowka/root rd.luks.uuid=luks-2d9b648a-15b1-4204-988b-ec085085f8ce rd.lvm.lv=fedora_krowka/swap LANG=en_US.UTF-8 selinux=0 resume='dev/mapper/fedora_krowka-swap systemd.show-status systemd.unit-status-format=name quiet\nlinux /08a5690md.unit-status-format=name quiet\nlinux /08a5690afeedfeedaaac0a5d2e3cf6b0/5.15.14-200.fc35.x86_64/linux\ninitrd /08a5690afeedfeedaaac0a5d2e3cf6b0/5.15.14-200.fc35.x86_64/titled\n"], ["08a5690afeedfeedaaac0a5d2e3cf6b0-5.17.47cf92ac0a5d2e3cf6b0-5.17.0-0.rc5.102.fc36.x86_64.conf", "title Fedora Lin38 6724b7a987ebb5b8495b9ea/3.8.0-2.fc19.armv7hl/tegra20-paz00.dtb\ndevicetree-overlay ", "title Fedora Lin3x 6724b7a987ebb5b8495_64/initrd\n"], ["08a5690afeedfeedaaac0a5d2e3cf6b0-5.17.0-0.rc5.102.fc36.x86_64.conf", "title Fedora Lin3x 6724b7a987ebb5b8495b9ea/3.8.0-2.fc19.armv7hl/tegra20-paz00.dtb\ndevicetree-overlay /6a9857a393'24b7a981ebb5b8495b9ea/overlays/overlay_A.dtbo /6a9857a393724b7a981ebb5b8495b9ea/overlays/overlay_B.dtbo\narchitecture IA32\narchitecture x64\narchitecture IA64\narcetithcure ARM\narchitecture AA64\n"]]}