summary refs log tree commit diff stats
path: root/util/aio-win32.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-02-21 16:47:54 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-03-13 15:23:37 +0400
commite2a3a2193ef2d252a1b3553e90895189a248bd22 (patch)
tree5d7fd694341bb14fbf331a7e10f14866a794abc6 /util/aio-win32.c
parent6eeef4477a8588f44a15458ab560c68d373d1033 (diff)
downloadfocaccia-qemu-e2a3a2193ef2d252a1b3553e90895189a248bd22.tar.gz
focaccia-qemu-e2a3a2193ef2d252a1b3553e90895189a248bd22.zip
aio/win32: aio_set_fd_handler() only supports SOCKET
Let's check if the argument is actually a SOCKET, else report an error
and return.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20230221124802.4103554-10-marcandre.lureau@redhat.com>
Diffstat (limited to 'util/aio-win32.c')
-rw-r--r--util/aio-win32.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/aio-win32.c b/util/aio-win32.c
index 74d63fa21e..08e8f5615d 100644
--- a/util/aio-win32.c
+++ b/util/aio-win32.c
@@ -22,6 +22,7 @@
 #include "qemu/sockets.h"
 #include "qapi/error.h"
 #include "qemu/rcu_queue.h"
+#include "qemu/error-report.h"
 
 struct AioHandler {
     EventNotifier *e;
@@ -70,10 +71,14 @@ void aio_set_fd_handler(AioContext *ctx,
                         IOHandler *io_poll_ready,
                         void *opaque)
 {
-    /* fd is a SOCKET in our case */
     AioHandler *old_node;
     AioHandler *node = NULL;
 
+    if (!fd_is_socket(fd)) {
+        error_report("fd=%d is not a socket, AIO implementation is missing", fd);
+        return;
+    }
+
     qemu_lockcnt_lock(&ctx->list_lock);
     QLIST_FOREACH(old_node, &ctx->aio_handlers, node) {
         if (old_node->pfd.fd == fd && !old_node->deleted) {