diff options
author | Werner Koch <[email protected]> | 2016-11-29 15:42:14 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-11-29 15:54:36 +0000 |
commit | a5910e00ace882b8a17169faf4607163ab454af9 (patch) | |
tree | c06918f086764efc6386f6c88dd3fc6c2caa8f96 /g10/plaintext.c | |
parent | gpg,sm: Merge the two versions of check_special_filename. (diff) | |
download | gnupg-a5910e00ace882b8a17169faf4607163ab454af9.tar.gz gnupg-a5910e00ace882b8a17169faf4607163ab454af9.zip |
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 <[email protected]>
Diffstat (limited to 'g10/plaintext.c')
-rw-r--r-- | g10/plaintext.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/g10/plaintext.c b/g10/plaintext.c index bdf55923b..40ce6030a 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -108,9 +108,25 @@ get_output_file (const byte *embedded_name, int embedded_namelen, } else if (iobuf_is_pipe_filename (fname) || !*fname) { - /* No filename or "-" given; write to stdout. */ - fp = es_stdout; - es_set_binary (fp); + /* Special file name, no filename, or "-" given; write to the + * file descriptor or to stdout. */ + 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 { |