vmm: Modernize get_smbios_table()
This commit is contained in:
+8
-12
@@ -261,22 +261,18 @@ static const SmbiosHeader *get_smbios_table(uint8_t type, uint64_t *ret_size_lef
|
|||||||
|
|
||||||
/* Skip over string table. */
|
/* Skip over string table. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
while (size > 0 && *p != '\0') {
|
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. */
|
||||||
p++;
|
p++;
|
||||||
size--;
|
size--;
|
||||||
}
|
|
||||||
if (size == 0)
|
|
||||||
return NULL;
|
|
||||||
p++;
|
|
||||||
size--;
|
|
||||||
|
|
||||||
/* Double NUL terminates string table. */
|
|
||||||
if (*p == '\0') {
|
|
||||||
if (size == 0)
|
|
||||||
return NULL;
|
|
||||||
p++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size -= e + 1 - p;
|
||||||
|
p = e + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user