]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not leak file handle on _open_osfhandle() xaccept() failure (#2231)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Wed, 10 Sep 2025 03:48:22 +0000 (03:48 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 10 Sep 2025 03:48:26 +0000 (03:48 +0000)
compat/socket.cc

index 5fac7c22448bcb6d447b6b0839108746f9d3ac31..fd3c5c4f3f4f5cea6e97a60d70ee24a1775cf7fe 100644 (file)
@@ -34,8 +34,10 @@ xaccept(int socketFd, struct sockaddr *sa, socklen_t *saLength)
         return SOCKET_ERROR;
     }
     const auto rv = _open_osfhandle(result, 0);
-    if (rv == -1)
+    if (rv == -1) {
+        closesocket(result);
         errno = EBADF;
+    }
     if (saLength)
         *saLength = static_cast<socklen_t>(al);
     return rv;