All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smbios: Fix buffer overrun when using path= option
@ 2025-03-23 21:35 Daan De Meyer
  2025-03-24  6:24 ` Thomas Huth
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Daan De Meyer @ 2025-03-23 21:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daan De Meyer

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: bb99f4772f54017490e3356ecbb3df25c5d4537f ("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 <daan.j.demeyer@gmail.com>
---
 hw/smbios/smbios.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 02a09eb9cd..ad4cd6721e 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,
             g_byte_array_append(data, (guint8 *)buf, ret);
         }
 
+        buf[0] = '\0';
+        g_byte_array_append(data, (guint8 *)buf, 1);
+
         qemu_close(fd);
 
         *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-04-08 14:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-23 21:35 [PATCH] smbios: Fix buffer overrun when using path= option Daan De Meyer
2025-03-24  6:24 ` Thomas Huth
2025-04-08 14:13   ` Stefan Hajnoczi
2025-03-24  9:12 ` Daniel P. Berrangé
2025-03-24 13:22   ` Daniel P. Berrangé
2025-03-31 22:18 ` Philippe Mathieu-Daudé
2025-04-03 19:29 ` Daan De Meyer
2025-04-03 19:37   ` Philippe Mathieu-Daudé
2025-04-04 14:46     ` Valentin David
2025-04-04 15:02       ` Philippe Mathieu-Daudé
2025-04-04 15:06         ` Valentin David

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.