mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
37343db08f
commit
250733c0d8
4 changed files with 52 additions and 41 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue