diff options
author | NIIBE Yutaka <[email protected]> | 2023-07-11 01:46:36 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-07-11 01:46:36 +0000 |
commit | 250733c0d86d392c6e37b62cc82df0c396362581 (patch) | |
tree | 500ef09b98a8cc8d6a1903a0deeddd99e4d04f64 /g10/plaintext.c | |
parent | common,gpg,kbx: Factor out open_stream_nc. (diff) | |
download | gnupg-250733c0d86d392c6e37b62cc82df0c396362581.tar.gz gnupg-250733c0d86d392c6e37b62cc82df0c396362581.zip |
common: Add gnupg_check_special_filename.
* common/sysutils.h (gnupg_check_special_filename): New.
* common/sysutils.c (gnupg_check_special_filename): New.
* common/iobuf.c (translate_file_handle): Remove.
(iobuf_is_pipe_filename): Use gnupg_check_special_filename.
(do_open): Use gnupg_check_special_filename.
* g10/plaintext.c (get_output_file): Use gnupg_check_special_filename
and open_stream_nc.
--
GnuPG-bug-id: 6580
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/plaintext.c')
-rw-r--r-- | g10/plaintext.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/g10/plaintext.c b/g10/plaintext.c index 3d54b843c..9544ddf03 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -111,20 +111,20 @@ get_output_file (const byte *embedded_name, int embedded_namelen, { /* Special file name, no filename, or "-" given; write to the * file descriptor or to stdout. */ - int fd; + gnupg_fd_t fd; char xname[64]; - fd = check_special_filename (fname, 1, 0); - if (fd == -1) + fd = gnupg_check_special_filename (fname); + if (fd == GNUPG_INVALID_FD) { /* Not a special filename, thus we want stdout. */ fp = es_stdout; es_set_binary (fp); } - else if (!(fp = es_fdopen_nc (fd, "wb"))) + else if (!(fp = open_stream_nc (fd, "wb"))) { err = gpg_error_from_syserror (); - snprintf (xname, sizeof xname, "[fd %d]", fd); + snprintf (xname, sizeof xname, "[fd %d]", (int)(intptr_t)fd); log_error (_("can't open '%s': %s\n"), xname, gpg_strerror (err)); goto leave; } |