From bc451f58e1a0cd3e43825d30315eb44430ce232a Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Mon, 17 Jan 2022 19:34:11 -0800 Subject: [PATCH] Fix dumb_socketpair() comments Forgot to commit these in final revision of https://gitlab.com/openconnect/openconnect/-/merge_requests/320 Signed-off-by: Daniel Lenski --- compat.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/compat.c b/compat.c index e7b56343..4c0863e3 100644 --- a/compat.c +++ b/compat.c @@ -416,6 +416,13 @@ int dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped) } socks[0] = socks[1] = -1; + /* AF_UNIX/SOCK_STREAM became available in Windows 10 + * ( https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows ) + * + * We will attempt to use AF_UNIX, but fallback to using AF_INET if + * setting up AF_UNIX socket fails in any other way, which it surely will + * on earlier versions of Windows. + */ for (ii = 0; ii < 2; ii++) { listener = socket(domain, SOCK_STREAM, domain == AF_INET ? IPPROTO_TCP : 0); if (listener == INVALID_SOCKET) @@ -443,8 +450,8 @@ int dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped) n = GetTempPath(UNIX_PATH_MAX, a.unaddr.sun_path); break; case 1: - /* Heckuva job with API consistency, Microsoft! - * unless the Windows directory is the root directory." + /* Heckuva job with API consistency, Microsoft! Reversed argument order, and + * "This path does not end with a backslash unless the Windows directory is the root directory.." */ n = GetWindowsDirectory(a.unaddr.sun_path, UNIX_PATH_MAX); n += snprintf(a.unaddr.sun_path + n, UNIX_PATH_MAX - n, "\\Temp\\"); @@ -513,12 +520,6 @@ int dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped) return 0; fallback: - /* AF_UNIX/SOCK_STREAM became available in Windows 10: - * https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows - * - * We need to fallback to AF_INET on earlier versions of Windows, - * or if setting up AF_UNIX socket fails in any other way. - */ domain = AF_INET; addrlen = sizeof(a.inaddr); -- 2.50.1