Commit 20a2f95615 for qemu.org
commit 20a2f956153e82b84fcb1be5b3a6ed2906f75e55
Author: Laurent Vivier <laurent@vivier.eu>
Date: Thu Aug 27 19:44:03 2026 +0200
hw/char/goldfish_tty: Fix signed data length
The guest-controlled data_len register is uint32_t, but was copied into
a signed int. A value of 0xffffffff consequently became -1, allowing the
DMA transfer size to exceed the 128-byte stack buffer.
Use an unsigned length variable so that each transfer remains bounded by
GOLFISH_TTY_BUFFER_SIZE.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4245
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-ID: <20260827174403.610834-1-laurent@vivier.eu>
diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c
index 8e1e9228c7..f64527f50a 100644
--- a/hw/char/goldfish_tty.c
+++ b/hw/char/goldfish_tty.c
@@ -71,7 +71,7 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
{
uint32_t to_copy;
uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE];
- int len;
+ unsigned int len;
uint64_t ptr;
switch (cmd) {