]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
In dumb_socketpair(), delete Unix-domain socket path once no longer needed
authorDaniel Lenski <dlenski@gmail.com>
Thu, 3 Feb 2022 22:12:17 +0000 (14:12 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Fri, 11 Feb 2022 18:07:23 +0000 (10:07 -0800)
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 <dlenski@gmail.com>
compat.c

index 4c0863e3f33762bfb5e8d8f771f0de32a7161139..ecaf87d3832f2fe9dc83de5cf1348d5ea292aff7 100644 (file)
--- 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)