Skip to content

Commit a7a05f5

Browse files
DaanDeMeyerphilmd
authored andcommitted
smbios: Fix buffer overrun when using path= option
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on. Fixes: bb99f47 ("hw/smbios: support loading OEM strings values from a file") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879 Signed-off-by: Daan De Meyer <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Tested-by: Valentin David <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent dfaecc0 commit a7a05f5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

hw/smbios/smbios.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,
12851285
g_byte_array_append(data, (guint8 *)buf, ret);
12861286
}
12871287

1288+
buf[0] = '\0';
1289+
g_byte_array_append(data, (guint8 *)buf, 1);
1290+
12881291
qemu_close(fd);
12891292

12901293
*opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);

0 commit comments

Comments
 (0)