summaryrefslogtreecommitdiffstats
path: root/src/boot
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-07-04 14:34:35 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2024-07-04 20:08:09 +0200
commit44ec70489f377d1fa9f4e19aed95a7e39da7d93d (patch)
treec583781dbc0e279e21c612d23107a7867bf2446b /src/boot
parentmeson: Fix various versions (diff)
downloadsystemd-44ec70489f377d1fa9f4e19aed95a7e39da7d93d.tar.xz
systemd-44ec70489f377d1fa9f4e19aed95a7e39da7d93d.zip
vmm: make sure we can handle smbios objects without variable part
An smbios object with no variable part is a special case, it's just suffixed with two NUL btes. handle that properly. This is inspired by a similar fix from https://github.com/systemd/systemd/pull/29726
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/vmm.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/boot/efi/vmm.c b/src/boot/efi/vmm.c
index 0f268a1512..87b692cc85 100644
--- a/src/boot/efi/vmm.c
+++ b/src/boot/efi/vmm.c
@@ -242,13 +242,21 @@ static const SmbiosHeader *get_smbios_table(uint8_t type, uint64_t *ret_size_lef
size -= header->length;
p += header->length;
- /* Skip over string table. */
+ /* Special case: if there are no strings appended, we'll see two NUL bytes, skip over them */
+ if (size >= 2 && p[0] == 0 && p[1] == 0) {
+ size -= 2;
+ p += 2;
+ continue;
+ }
+
+ /* Skip over a populated string table. */
+ bool first = true;
for (;;) {
const uint8_t *e = memchr(p, 0, size);
if (!e)
return NULL;
- if (e == p) {/* Double NUL byte means we've reached the end of the string table. */
+ if (!first && e == p) {/* Double NUL byte means we've reached the end of the string table. */
p++;
size--;
break;
@@ -256,6 +264,7 @@ static const SmbiosHeader *get_smbios_table(uint8_t type, uint64_t *ret_size_lef
size -= e + 1 - p;
p = e + 1;
+ first = false;
}
}