From 250733c0d86d392c6e37b62cc82df0c396362581 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 11 Jul 2023 10:46:36 +0900 Subject: 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 --- g10/plaintext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'g10/plaintext.c') 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; } -- cgit v1.2.3