Skip to contentSkip to conversation

hw/char/goldfish_tty: Fix signed data length

PATCH New Laurent Vivier 1 participant 1 message Aug 27

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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

---
 hw/char/goldfish_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/goldfish_tty.c +1 -1
index 8e1e9228c78b..f64527f50a02 100644
@@ -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) {
Signature · 1 line
2.55.0