From: Guus Sliepen Date: Sun, 27 Jun 2021 14:06:58 +0000 (+0200) Subject: Fix for the event loop on Windows. X-Git-Tag: release-1.1pre18~7 X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=2a441065a26f9796cdbc6e4ade50409b91d73f7e Fix for the event loop on Windows. The code did not take into account that the return value of WSAWaitForMultipleEvents() is the offset into the event array plus WSA_WAIT_EVENT_0. Based on a patch from arsh0r. --- diff --git a/src/event.c b/src/event.c index 1283edd3..1ca15d20 100644 --- a/src/event.c +++ b/src/event.c @@ -435,12 +435,12 @@ bool event_loop(void) { break; } - if(result >= event_count - event_offset) { - return(false); + if(result < WSA_WAIT_EVENT_0 || result >= WSA_WAIT_EVENT_0 + event_count - event_offset) { + return false; } /* Look up io in the map by index. */ - event_index = result - event_offset; + event_index = result - WSA_WAIT_EVENT_0 + event_offset; io_t *io = io_map[event_index]; if(io->fd == -1) {