From ec9d20e9f7a1339f93cac94978c0c6d0ac64a516 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Thu, 3 Feb 2022 14:12:17 -0800 Subject: [PATCH] In dumb_socketpair(), delete Unix-domain socket path once no longer needed Small follow-up improvement to https://gitlab.com/openconnect/openconnect/-/merge_requests/320, which made dumb_socketpair() able to use Unix-domain sockets, on those Windows versions that support them albeit only with named paths. This was suggested as a way to prevent the Windows dumb_socketpair() implementation from leaving behind size-0 files, even if normally only in temporary directories. See original suggestion at https://github.com/microsoft/WSL/issues/4240#issuecomment-1027607891. Signed-off-by: Daniel Lenski --- compat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat.c b/compat.c index 4c0863e3..ecaf87d3 100644 --- a/compat.c +++ b/compat.c @@ -511,6 +511,8 @@ int dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped) goto fallback; if (connect(socks[0], &a.addr, addrlen) == SOCKET_ERROR) goto fallback; + if (domain == AF_UNIX) + DeleteFile(a.unaddr.sun_path); // Socket file no longer needed socks[1] = accept(listener, NULL, NULL); if (socks[1] == INVALID_SOCKET)