diff options
author | NIIBE Yutaka <[email protected]> | 2023-06-27 05:44:01 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-06-27 05:44:01 +0000 |
commit | b9b0c183204f81ae12b31ef15045ebee98a4c970 (patch) | |
tree | 9cf0a61b0a17b9a21b89f32aad996341200708d9 /common/sysutils.c | |
parent | agent: Fix cast mistake for Windows. (diff) | |
download | gnupg-b9b0c183204f81ae12b31ef15045ebee98a4c970.tar.gz gnupg-b9b0c183204f81ae12b31ef15045ebee98a4c970.zip |
common,gpg,sm,tools: Don't remove translate_sys2libc_fd_int.
* common/sysutils.c (translate_sys2libc_fd_int): Recover.
(translate_sys2libc_fdstr): Remove.
(check_special_filename): Follow the change.
* common/sysutils.h (translate_sys2libc_fd_int): Recover.
(translate_sys2libc_fdstr): Remove.
* g10/gpg.c, g10/gpgv.c, sm/gpgsm.c: Revert the changes.
* tools/gpg-auth.c, tools/gpg-card.c, tools/gpg-pair-tool.c: Likewise.
* tools/gpg-wks-client.c, tools/gpgconf.c: Likewise.
--
GnuPG-bug-id: 6551
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'common/sysutils.c')
-rw-r--r-- | common/sysutils.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/common/sysutils.c b/common/sysutils.c index 7c3667ce7..042387297 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -556,6 +556,24 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write) #endif } +/* This is the same as translate_sys2libc_fd but takes an integer + which is assumed to be such an system handle. On WindowsCE the + passed FD is a rendezvous ID and the function finishes the pipe + creation. */ +int +translate_sys2libc_fd_int (int fd, int for_write) +{ +#ifdef HAVE_W32_SYSTEM + if (fd <= 2) + return fd; /* Do not do this for error, stdin, stdout, stderr. */ + + return translate_sys2libc_fd ((void*)fd, for_write); +#else + (void)for_write; + return fd; +#endif +} + /* * Parse the string representation of a file reference (file handle on @@ -636,30 +654,6 @@ gnupg_sys2libc_fdstr (const char *fdstr, int for_write, #endif } -/* This is the same as translate_sys2libc_fd but takes a string - which represents a system handle on Windows a file descriptor - on POSIX. - - (1) 0, 1, or 2 which means stdin, stdout, and stderr, respectively. - (2) Integer representation (by %d of printf). - (3) Hex representation which starts as "0x". -*/ -int -translate_sys2libc_fdstr (const char *fdstr, int for_write) -{ - gpg_error_t err; - int fd; - - err = gnupg_sys2libc_fdstr (fdstr, for_write, NULL, &fd); - if (err) - { - log_error ("FDSTR error: %s\n", fdstr); - return -1; - } - - return fd; -} - /* Check whether FNAME has the form "-&nnnn", where N is a non-zero * number. Returns this number or -1 if it is not the case. If the @@ -679,7 +673,7 @@ check_special_filename (const char *fname, int for_write, int notranslate) ; if (!fname[i]) return notranslate? atoi (fname) - /**/ : translate_sys2libc_fdstr (fname, for_write); + /**/ : translate_sys2libc_fd_int (atoi (fname), for_write); } return -1; } |