1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-02 22:38:02 +02:00

gpg: Make --decrypt with output '-&nnnn' work.

* g10/plaintext.c (get_output_file): Check and open special filename
before falling back to stdout.
--

GnuPG-bug-id: 2677
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-11-29 16:42:14 +01:00
parent 60b4982836
commit a5910e00ac
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -108,9 +108,25 @@ get_output_file (const byte *embedded_name, int embedded_namelen,
} }
else if (iobuf_is_pipe_filename (fname) || !*fname) else if (iobuf_is_pipe_filename (fname) || !*fname)
{ {
/* No filename or "-" given; write to stdout. */ /* Special file name, no filename, or "-" given; write to the
fp = es_stdout; * file descriptor or to stdout. */
es_set_binary (fp); int fd;
char xname[64];
fd = check_special_filename (fname, 1, 0);
if (fd == -1)
{
/* Not a special filename, thus we want stdout. */
fp = es_stdout;
es_set_binary (fp);
}
else if (!(fp = es_fdopen_nc (fd, "wb")))
{
err = gpg_error_from_syserror ();
snprintf (xname, sizeof xname, "[fd %d]", fd);
log_error (_("can't open '%s': %s\n"), xname, gpg_strerror (err));
goto leave;
}
} }
else else
{ {