From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Daan De Meyer" <daan.j.demeyer@gmail.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Valentin David" <valentin.david@canonical.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 1/8] smbios: Fix buffer overrun when using path= option
Date: Tue, 8 Apr 2025 20:55:31 +0200 [thread overview]
Message-ID: <20250408185538.85538-2-philmd@linaro.org> (raw)
In-Reply-To: <20250408185538.85538-1-philmd@linaro.org>
From: Daan De Meyer <daan.j.demeyer@gmail.com>
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>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Valentin David <valentin.david@canonical.com>
Message-ID: <20250323213622.2581013-1-daan.j.demeyer@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/smbios/smbios.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 02a09eb9cd0..ad4cd6721e6 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.47.1
next prev parent reply other threads:[~2025-04-08 18:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 18:55 [PULL 0/8] Misc HW patches for 2025-04-08 Philippe Mathieu-Daudé
2025-04-08 18:55 ` Philippe Mathieu-Daudé [this message]
2025-04-17 10:11 ` [PULL 1/8] smbios: Fix buffer overrun when using path= option Daan De Meyer
2025-04-17 13:05 ` Michael Tokarev
2025-04-17 13:25 ` Daan De Meyer
2025-04-17 13:56 ` Philippe Mathieu-Daudé
2025-04-08 18:55 ` [PULL 2/8] hw/core/machine: Fix -machine dumpdtb=file.dtb Philippe Mathieu-Daudé
2025-05-08 13:46 ` Peter Maydell
2025-04-08 18:55 ` [PULL 3/8] docs/arm: Add apple HVF host for supported guest CPU type Philippe Mathieu-Daudé
2025-04-08 18:55 ` [PULL 4/8] hw/ufs: Fix incorrect comment for segment_size and allocation_unit_size Philippe Mathieu-Daudé
2025-04-08 18:55 ` [PULL 5/8] hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties from devicetree Philippe Mathieu-Daudé
2025-04-08 18:55 ` [PULL 6/8] hw/arm/imx8mp-evk: Temporarily remove unimplemented imx8mp-fspi node " Philippe Mathieu-Daudé
2025-04-08 18:55 ` [PULL 7/8] hw/nvme: fix attachment of private namespaces Philippe Mathieu-Daudé
2025-04-08 18:55 ` [PULL 8/8] scripts/checkpatch: Fix typo in SPDX-License-Identifier keyword Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250408185538.85538-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=daan.j.demeyer@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=valentin.david@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).