From a7cff718920c56782e805a9b097b2d60136e5962 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 22 Aug 2024 13:16:29 -0300 Subject: [PATCH 1/4] OPTi 5x7: Fix out of bounds on register read --- src/chipset/opti5x7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chipset/opti5x7.c b/src/chipset/opti5x7.c index 64adacde4..b31996c85 100644 --- a/src/chipset/opti5x7.c +++ b/src/chipset/opti5x7.c @@ -158,7 +158,7 @@ opti5x7_read(uint16_t addr, void *priv) { const opti5x7_t *dev = (opti5x7_t *) priv; - return (addr == 0x24) ? dev->regs[dev->idx] : 0xff; + return ((addr == 0x24) && (dev->idx < sizeof(dev->regs))) ? dev->regs[dev->idx] : 0xff; } static void From 8d88d187b29f4365ba31529eff1baa7361a54276 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 22 Aug 2024 14:21:36 -0300 Subject: [PATCH 2/4] gdbstub: Work around Win32 threading behavior --- src/gdbstub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gdbstub.c b/src/gdbstub.c index 900f40dab..2f60a3d16 100644 --- a/src/gdbstub.c +++ b/src/gdbstub.c @@ -1513,6 +1513,7 @@ gdbstub_client_thread(void *priv) case '$': /* packet start */ /* Wait for any existing packets to be processed. */ thread_wait_event(client->processed_event, -1); + thread_set_event(client->processed_event); client->packet_pos = 0; break; @@ -1539,6 +1540,7 @@ gdbstub_client_thread(void *priv) default: /* Wait for any existing packets to be processed, just in case. */ thread_wait_event(client->processed_event, -1); + thread_set_event(client->processed_event); if (client->packet_pos < (sizeof(client->packet) - 1)) { /* Append byte to the packet. */ From d697d9bca1c6385e44b8bd12769864e1e3da22cb Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 22 Aug 2024 14:50:10 -0300 Subject: [PATCH 3/4] OPTi 5x7: Fix another out of bounds on register write --- src/chipset/opti5x7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chipset/opti5x7.c b/src/chipset/opti5x7.c index b31996c85..494fdee64 100644 --- a/src/chipset/opti5x7.c +++ b/src/chipset/opti5x7.c @@ -35,7 +35,7 @@ typedef struct opti5x7_t { uint8_t idx; uint8_t is_pci; - uint8_t regs[16]; + uint8_t regs[18]; } opti5x7_t; #ifdef ENABLE_OPTI5X7_LOG From 3b47f0590c24abece872965b6f555856cf3fa035 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 22 Aug 2024 15:45:32 -0300 Subject: [PATCH 4/4] gdbstub: Fix another Win32 threading deadlock --- src/gdbstub.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gdbstub.c b/src/gdbstub.c index 2f60a3d16..42e1fc46d 100644 --- a/src/gdbstub.c +++ b/src/gdbstub.c @@ -1531,6 +1531,7 @@ gdbstub_client_thread(void *priv) case 0x03: /* break */ /* Wait for any existing packets to be processed. */ thread_wait_event(client->processed_event, -1); + thread_set_event(client->processed_event); /* Break immediately. */ gdbstub_log("GDB Stub: Break requested\n");