qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/3] util/main-loop: Fix maximum number of wait objects for win32
@ 2022-10-19 10:20 Bin Meng
  2022-10-19 10:20 ` [PATCH v4 2/3] util/main-loop: Avoid adding the same HANDLE twice Bin Meng
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Bin Meng @ 2022-10-19 10:20 UTC (permalink / raw)
  To: qemu-devel, Daniel P . Berrangé, Marc-André Lureau
  Cc: Bin Meng, Paolo Bonzini

From: Bin Meng <bin.meng@windriver.com>

The maximum number of wait objects for win32 should be
MAXIMUM_WAIT_OBJECTS, not MAXIMUM_WAIT_OBJECTS + 1.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

Changes in v4:
- make the out of bounds access protection explicit

Changes in v3:
- move the check of adding the same HANDLE twice to a separete patch

Changes in v2:
- fix the logic in qemu_add_wait_object() to avoid adding
  the same HANDLE twice

 util/main-loop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/util/main-loop.c b/util/main-loop.c
index f00a25451b..de38876064 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -363,10 +363,10 @@ void qemu_del_polling_cb(PollingFunc *func, void *opaque)
 /* Wait objects support */
 typedef struct WaitObjects {
     int num;
-    int revents[MAXIMUM_WAIT_OBJECTS + 1];
-    HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
-    WaitObjectFunc *func[MAXIMUM_WAIT_OBJECTS + 1];
-    void *opaque[MAXIMUM_WAIT_OBJECTS + 1];
+    int revents[MAXIMUM_WAIT_OBJECTS];
+    HANDLE events[MAXIMUM_WAIT_OBJECTS];
+    WaitObjectFunc *func[MAXIMUM_WAIT_OBJECTS];
+    void *opaque[MAXIMUM_WAIT_OBJECTS];
 } WaitObjects;
 
 static WaitObjects wait_objects = {0};
@@ -395,7 +395,7 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
         if (w->events[i] == handle) {
             found = 1;
         }
-        if (found) {
+        if (found && i < (MAXIMUM_WAIT_OBJECTS - 1)) {
             w->events[i] = w->events[i + 1];
             w->func[i] = w->func[i + 1];
             w->opaque[i] = w->opaque[i + 1];
-- 
2.34.1



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

end of thread, other threads:[~2022-11-01 17:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-19 10:20 [PATCH v4 1/3] util/main-loop: Fix maximum number of wait objects for win32 Bin Meng
2022-10-19 10:20 ` [PATCH v4 2/3] util/main-loop: Avoid adding the same HANDLE twice Bin Meng
2022-11-01 13:40   ` Philippe Mathieu-Daudé
2022-10-19 10:20 ` [PATCH v4 3/3] util/aio-win32: Correct the event array size in aio_poll() Bin Meng
2022-11-01 13:41   ` Philippe Mathieu-Daudé
2022-10-25 16:41 ` [PATCH v4 1/3] util/main-loop: Fix maximum number of wait objects for win32 Bin Meng
2022-11-01  1:14   ` Bin Meng
2022-11-01 12:03     ` Daniel P. Berrangé
2022-11-01 13:06       ` Bin Meng
2022-11-01 13:40 ` Philippe Mathieu-Daudé

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).