From 795b52e7e910225a0f9307260b8d599ed0b20dba Mon Sep 17 00:00:00 2001 From: Martin Fernandez Date: Wed, 19 Apr 2023 12:44:51 +0800 Subject: [PATCH] Compare with AGENT_PIPE_ID --- contrib/win32/win32compat/w32fd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/win32/win32compat/w32fd.c b/contrib/win32/win32compat/w32fd.c index 732c1c4b5094..5255518e19c3 100644 --- a/contrib/win32/win32compat/w32fd.c +++ b/contrib/win32/win32compat/w32fd.c @@ -326,7 +326,11 @@ w32_afunix_socket(struct sockaddr_un* addr) a AF_UNIX socket if ssh forwarding is enabled. If the addr->sun_path is the the well known named pipe, we open the socket with w32_fileio. */ - if(strcmp(addr->sun_path, "\\\\.\\pipe\\openssh-ssh-agent") == 0) + int len = wcslen(AGENT_PIPE_ID); + char* pipeid = (char*)malloc(len + 1); + memset(pipeid, 0, len + 1); + + if(wcstombs(pipeid, AGENT_PIPE_ID, len + 1) == (size_t) -1 && strcmp(addr->sun_path, pipeid) == 0) return w32_fileio_socket(SOCK_STREAM, 0); else return w32_unix_socket(SOCK_STREAM, 0);