aboutsummaryrefslogtreecommitdiffstats
path: root/common/sysutils.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2023-06-29 05:01:40 +0000
committerNIIBE Yutaka <[email protected]>2023-06-29 05:01:40 +0000
commit3672c29156e3678014b16875ba8895cf5f02cafe (patch)
treecd320411bf2800d44fa8033ea3b8a686a68449a3 /common/sysutils.c
parenttools:gpgtar: Clean up the use of --status-fd. (diff)
downloadgnupg-3672c29156e3678014b16875ba8895cf5f02cafe.tar.gz
gnupg-3672c29156e3678014b16875ba8895cf5f02cafe.zip
common: Raise an error correctly in check_special_filename.
* common/sysutils.c (check_special_filename): Use gnupg_parse_fdstr to check an error. -- GnuPG-bug-id: 6551 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'common/sysutils.c')
-rw-r--r--common/sysutils.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/common/sysutils.c b/common/sysutils.c
index 5dfbb72e7..a780d564f 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -656,8 +656,27 @@ check_special_filename (const char *fname, int for_write, int notranslate)
for (i=0; digitp (fname+i); i++ )
;
if (!fname[i])
- return notranslate? atoi (fname)
- /**/ : translate_sys2libc_fd_int (atoi (fname), for_write);
+ {
+ if (notranslate)
+ return atoi (fname);
+ else
+ {
+ es_syshd_t syshd;
+
+ if (gnupg_parse_fdstr (fname, &syshd))
+ return -1;
+
+#ifdef HAVE_W32_SYSTEM
+ if (syshd.type == ES_SYSHD_FD)
+ return syshd.u.fd;
+ else
+ return translate_sys2libc_fd ((gnupg_fd_t)syshd.u.handle, for_write);
+#else
+ (void)for_write;
+ return syshd.u.fd;
+#endif
+ }
+ }
}
return -1;
}