From cf8afb9490da651f382c4c3d9be8dc5aaf2ee62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Mar 2026 10:36:59 +0100 Subject: [PATCH] Safety check in sceNetInetSelect --- Core/HLE/sceNetInet.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Core/HLE/sceNetInet.cpp b/Core/HLE/sceNetInet.cpp index aa8431742e..83683c7c94 100644 --- a/Core/HLE/sceNetInet.cpp +++ b/Core/HLE/sceNetInet.cpp @@ -252,6 +252,10 @@ int sceNetInetSelect(int nfds, u32 readfdsPtr, u32 writefdsPtr, u32 exceptfdsPtr if (readfds && (NetInetFD_ISSET(i, readfds))) { SOCKET sock = g_socketManager.GetHostSocketFromInetSocket(i); _dbg_assert_(sock != 0); + if (sock < 0) { + ERROR_LOG(Log::sceNet, "Bad socket #%d in readfds", i); + continue; + } hostSockets[i] = sock; if (sock > maxHostSocket) maxHostSocket = sock; @@ -266,6 +270,10 @@ int sceNetInetSelect(int nfds, u32 readfdsPtr, u32 writefdsPtr, u32 exceptfdsPtr if (writefds && (NetInetFD_ISSET(i, writefds))) { SOCKET sock = g_socketManager.GetHostSocketFromInetSocket(i); _dbg_assert_(sock != 0); + if (sock < 0) { + ERROR_LOG(Log::sceNet, "Bad socket #%d in writefds", i); + continue; + } hostSockets[i] = sock; if (sock > maxHostSocket) maxHostSocket = sock; @@ -280,6 +288,10 @@ int sceNetInetSelect(int nfds, u32 readfdsPtr, u32 writefdsPtr, u32 exceptfdsPtr if (exceptfds && (NetInetFD_ISSET(i, exceptfds))) { SOCKET sock = g_socketManager.GetHostSocketFromInetSocket(i); _dbg_assert_(sock != 0); + if (sock < 0) { + ERROR_LOG(Log::sceNet, "Bad socket #%d in exceptfds", i); + continue; + } hostSockets[i] = sock; if (sock > maxHostSocket) maxHostSocket = sock;