projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
717af0d
)
vmm: Modernize get_smbios_table()
author
Daan De Meyer
<daan.j.demeyer@gmail.com>
Wed, 22 Feb 2023 16:04:58 +0000
(17:04 +0100)
committer
Daan De Meyer
<daan.j.demeyer@gmail.com>
Thu, 23 Feb 2023 08:51:20 +0000
(09:51 +0100)
src/boot/efi/vmm.c
patch
|
blob
|
history
diff --git
a/src/boot/efi/vmm.c
b/src/boot/efi/vmm.c
index 1e6d4de4a6395e3082569d91bd131ab2b45dd967..cfdd5b01a957b114a2a19fd3eed343ea82a30711 100644
(file)
--- 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;
}
}