Skip to contentSkip to conversation

hw/uefi: fix parse_hexstr

PATCH In review Gerd Hoffmann 2 participants 2 messages May 26

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/uefi: fix parse_hexstr

Make sure we actually have two input characters available before going to parse two hex digits. Fixes one byte buffer overflow of the output buffer in case the input string has an odd number of characters.

Fixes CVE-2026-48915
Fixes 12058948abdf ("hw/uefi: add var-service-json.c + qapi for NV vars.")
---
 hw/uefi/var-service-json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/uefi/var-service-json.c +1 -1
index f5f155683334..8621b86c5c5f 100644
@@ -98,7 +98,7 @@ static void parse_hexstr(void *dest, char *src, int len)
     uint8_t *data = dest;
     size_t i;
 
-    for (i = 0; i < len; i += 2) {
+    for (i = 0; i + 1 < len; i += 2) {
         *(data++) =
             parse_hexchar(src[i]) << 4 |
             parse_hexchar(src[i + 1]);
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Gerd Hoffmann

Make sure we actually have two input characters available before going to parse two hex digits. Fixes one byte buffer overflow of the output buffer in case the input string has an odd number of characters.

Fixes CVE-2026-48915
Fixes 12058948abdf ("hw/uefi: add var-service-json.c + qapi for NV vars.")
---
  hw/uefi/var-service-json.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)