From 6ba87a5b9a8b2104e83fd46d38c1746f2a386598 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Fri, 23 Feb 2024 21:58:40 +0300 Subject: [PATCH] Don't read() from the invalid descriptor Having the invalid value of descriptor here might be considered weird, but it happens nevertheless, when you're DoSing the websocket endpoint using the 3G connection. It makes sense to return the generic error here instead of trying to read() from it. --- ixwebsocket/IXSelectInterruptPipe.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ixwebsocket/IXSelectInterruptPipe.cpp b/ixwebsocket/IXSelectInterruptPipe.cpp index 75c42f27..26a6d4c6 100644 --- a/ixwebsocket/IXSelectInterruptPipe.cpp +++ b/ixwebsocket/IXSelectInterruptPipe.cpp @@ -134,6 +134,9 @@ namespace ix int fd = _fildes[kPipeReadIndex]; + // A weird state has been reached (consider reporting to the error log?) + if (-1 == fd) return std::numeric_limits::max(); + uint64_t value = 0; ssize_t ret = -1;