From 17055e1c995367e60f45ee73fa1a39e7a09efd59 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 10 May 2023 13:24:43 +0900 Subject: w32: Fix the semantics of sending FD, it's Windows HANDLE. * src/assuan-handler.c (w32_handler_sendfd): It's Windows HANDLE. * src/system-w32.c (get_file_handle, w32_fdpass_send): Likewise. * tests/fdpassing.c (cmd_echo): Received FD is Windows HANDLE. (client): Use Windows HANDLE for assuan_sendfd. -- GnuPG-bug-id: 6236 Signed-off-by: NIIBE Yutaka --- src/assuan-handler.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/assuan-handler.c') diff --git a/src/assuan-handler.c b/src/assuan-handler.c index 37f84b6..a04ab4e 100644 --- a/src/assuan-handler.c +++ b/src/assuan-handler.c @@ -27,9 +27,6 @@ #include #include #include -#if HAVE_W32_SYSTEM || HAVE_W64_SYSTEM -#include -#endif #include "assuan-defs.h" #include "debug.h" @@ -359,10 +356,11 @@ std_handler_output (assuan_context_t ctx, char *line) } -#if HAVE_W32_SYSTEM || HAVE_W64_SYSTEM +#ifdef HAVE_W32_SYSTEM /* - * The command used by a client to send FD. That is, from the viewpoint - * of handling this command, it is to _receive_ a file handle. + * The command used by a client to send an FD. That is, from the + * viewpoint of handling this command, it is to _receive_ a file + * handle. */ static const char w32_help_sendfd[] = "SENDFD \n" @@ -375,7 +373,6 @@ w32_handler_sendfd (assuan_context_t ctx, char *line) gpg_error_t err = 0; char *endp; intptr_t file_handle; - int fd; #if HAVE_W64_SYSTEM file_handle = strtoull (line, &endp, 16); @@ -389,14 +386,7 @@ w32_handler_sendfd (assuan_context_t ctx, char *line) return PROCESS_DONE (ctx, err); } - fd = _open_osfhandle ((intptr_t)file_handle, _O_RDWR); - if (fd < 0) - { - CloseHandle ((HANDLE)file_handle); - err = GPG_ERR_ASSUAN; - } - - ctx->uds.pendingfds[ctx->uds.pendingfdscount++] = (assuan_fd_t)fd; + ctx->uds.pendingfds[ctx->uds.pendingfdscount++] = (assuan_fd_t)file_handle; return PROCESS_DONE (ctx, err); } #endif -- cgit v1.2.3