summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-02-22 17:04:58 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-02-23 09:51:20 +0100
commitc8e5d82c97a1478b15d2f97ffebd9591e81663ba (patch)
treef8ce47f3dc1407ad7e4117c77d1be16ebe1dca96 /src/boot
parent717af0de4648ccc223f06683a6baf73d64271e02 (diff)
downloadsystemd-c8e5d82c97a1478b15d2f97ffebd9591e81663ba.tar.gz
vmm: Modernize get_smbios_table()
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/vmm.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/boot/efi/vmm.c b/src/boot/efi/vmm.c
index 1e6d4de4a6..cfdd5b01a9 100644
--- a/src/boot/efi/vmm.c
+++ b/src/boot/efi/vmm.c
@@ -261,22 +261,18 @@ static const SmbiosHeader *get_smbios_table(uint8_t type, uint64_t *ret_size_lef
/* Skip over string table. */
for (;;) {
- while (size > 0 && *p != '\0') {
- p++;
- size--;
- }
- if (size == 0)
+ const uint8_t *e = memchr(p, 0, size);
+ if (!e)
return NULL;
- p++;
- size--;
- /* Double NUL terminates string table. */
- if (*p == '\0') {
- if (size == 0)
- return NULL;
+ if (e == p) {/* Double NUL byte means we've reached the end of the string table. */
p++;
+ size--;
break;
}
+
+ size -= e + 1 - p;
+ p = e + 1;
}
}