diff options
author | NIIBE Yutaka <[email protected]> | 2023-05-10 04:24:43 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-05-10 04:24:43 +0000 |
commit | 17055e1c995367e60f45ee73fa1a39e7a09efd59 (patch) | |
tree | 9408cb9597e4f31b37dca4367e1f74b477681b72 /tests | |
parent | Implement timeout in assuan_sock_connect_byname. (diff) | |
download | libassuan-17055e1c995367e60f45ee73fa1a39e7a09efd59.tar.gz libassuan-17055e1c995367e60f45ee73fa1a39e7a09efd59.zip |
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 <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fdpassing.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/fdpassing.c b/tests/fdpassing.c index 3caa4b2..438c8c5 100644 --- a/tests/fdpassing.c +++ b/tests/fdpassing.c @@ -30,6 +30,7 @@ # include <windows.h> # include <wincrypt.h> # include <io.h> +#include <fcntl.h> #else # include <sys/socket.h> # include <sys/un.h> @@ -54,12 +55,24 @@ cmd_echo (assuan_context_t ctx, char *line) int c; FILE *fp; int nbytes; +#ifdef HAVE_W32_SYSTEM + HANDLE file_handle; +#endif log_info ("got ECHO command (%s)\n", line); +#if HAVE_W32_SYSTEM + file_handle = assuan_get_input_fd (ctx); + if (file_handle == ASSUAN_INVALID_FD) + return gpg_error (GPG_ERR_ASS_NO_INPUT); + fd = _open_osfhandle ((intptr_t)file_handle, _O_RDONLY); + if (fd < 0) + return gpg_error (GPG_ERR_ASS_NO_INPUT); +#else fd = (int)assuan_get_input_fd (ctx); if (fd == -1) return gpg_error (GPG_ERR_ASS_NO_INPUT); +#endif fp = fdopen (fd, "r"); if (!fp) { @@ -234,6 +247,9 @@ client (assuan_context_t ctx, const char *fname) int rc; FILE *fp; int i; +#if HAVE_W32_SYSTEM + HANDLE file_handle; +#endif log_info ("client started. Servers's pid is %ld\n", (long)assuan_get_pid (ctx)); @@ -248,7 +264,12 @@ client (assuan_context_t ctx, const char *fname) return -1; } +#ifdef HAVE_W32_SYSTEM + file_handle = (HANDLE)_get_osfhandle (fileno (fp)); + rc = assuan_sendfd (ctx, file_handle); +#else rc = assuan_sendfd (ctx, (assuan_fd_t)fileno (fp)); +#endif if (rc) { fclose (fp); |