diff options
author | Werner Koch <[email protected]> | 2019-05-17 11:40:24 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-05-17 11:42:42 +0000 |
commit | 1702179d91b7136661af084d7dab2e50a2857491 (patch) | |
tree | ce7005d742e89ce779e14b6207b82b194122a13b | |
parent | gpg: Improve the photo image viewer selection. (diff) | |
download | gnupg-1702179d91b7136661af084d7dab2e50a2857491.tar.gz gnupg-1702179d91b7136661af084d7dab2e50a2857491.zip |
gpg: Fix using --decrypt along with --use-embedded-filename.
* g10/options.h (opt): Add flags.dummy_outfile.
* g10/decrypt.c (decrypt_message): Set this global flag instead of the
fucntion local flag.
* g10/plaintext.c (get_output_file): Ignore opt.output if that was
used as a dummy option aslong with --use-embedded-filename.
--
The problem here was that an explicit specified --decrypt, as
meanwhile suggested, did not work with that dangerous
--use-embedded-filename. In contrast it worked when gpg decrypted as
a side-effect of parsing the data.
GnuPG-bug-id: 4500
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | doc/gpg.texi | 3 | ||||
-rw-r--r-- | g10/decrypt.c | 7 | ||||
-rw-r--r-- | g10/options.h | 2 | ||||
-rw-r--r-- | g10/plaintext.c | 3 |
4 files changed, 10 insertions, 5 deletions
diff --git a/doc/gpg.texi b/doc/gpg.texi index 8aaf8db0f..67f0e8b11 100644 --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -2976,7 +2976,8 @@ to display the message. This option overrides @option{--set-filename}. @itemx --no-use-embedded-filename @opindex use-embedded-filename Try to create a file with a name as embedded in the data. This can be -a dangerous option as it enables overwriting files. Defaults to no. +a dangerous option as it enables overwriting files. Defaults to no. +Note that the option @option{--output} overrides this option. @item --cipher-algo @var{name} @opindex cipher-algo diff --git a/g10/decrypt.c b/g10/decrypt.c index 4d6734d40..9589aff58 100644 --- a/g10/decrypt.c +++ b/g10/decrypt.c @@ -48,7 +48,6 @@ decrypt_message (ctrl_t ctrl, const char *filename) armor_filter_context_t *afx = NULL; progress_filter_context_t *pfx; int rc; - int no_out = 0; pfx = new_progress_context (); @@ -82,11 +81,13 @@ decrypt_message (ctrl_t ctrl, const char *filename) if (!opt.outfile) { - no_out = 1; opt.outfile = "-"; + opt.flags.dummy_outfile = 1; } + else + opt.flags.dummy_outfile = 0; rc = proc_encryption_packets (ctrl, NULL, fp ); - if (no_out) + if (opt.flags.dummy_outfile) opt.outfile = NULL; iobuf_close (fp); diff --git a/g10/options.h b/g10/options.h index 782c0cbab..a7677e605 100644 --- a/g10/options.h +++ b/g10/options.h @@ -241,6 +241,8 @@ struct unsigned int disable_signer_uid:1; /* Flag to enable experimental features from RFC4880bis. */ unsigned int rfc4880bis:1; + /* Hack: --output is not given but OUTFILE was temporary set to "-". */ + unsigned int dummy_outfile:1; } flags; /* Linked list of ways to find a key if the key isn't on the local diff --git a/g10/plaintext.c b/g10/plaintext.c index c5d1ddb7f..f9e0a4296 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -70,7 +70,8 @@ get_output_file (const byte *embedded_name, int embedded_namelen, goto leave; } } - else if (opt.outfile) + else if (opt.outfile + && !(opt.flags.use_embedded_filename && opt.flags.dummy_outfile)) { fname = xtrystrdup (opt.outfile); if (!fname) |