diff options
Diffstat (limited to 'g10/verify.c')
-rw-r--r-- | g10/verify.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/g10/verify.c b/g10/verify.c index 924fc85ce..db7dd5e70 100644 --- a/g10/verify.c +++ b/g10/verify.c @@ -24,6 +24,7 @@ #include <string.h> #include <errno.h> #include <assert.h> +#include <unistd.h> /* for isatty() */ #include "options.h" #include "packet.h" @@ -60,6 +61,31 @@ verify_signatures( int nfiles, char **files ) STRLIST sl; memset( &afx, 0, sizeof afx); + /* decide whether we should handle a detached or a normal signature, + * which is needed so that the code later can hash the correct data and + * not have a normal signature act as detached signature and ignoring the + * indended signed material from the 2nd file or stdin. + * 1. gpg <file - normal + * 2. gpg file - normal (or detached) + * 3. gpg file <file2 - detached + * 4. gpg file file2 - detached + * The question is how decide between case 2 and 3? The only way + * we can do it is by reading one byte from stdin and the unget + * it; the problem here is that we may be reading from the + * terminal (which could be detected using isatty() but won't work + * when under contol of a pty using program (e.g. expect)) and + * might get us in trouble when stdin is used for another purpose + * (--passphrase-fd 0). So we have to break with the behaviour + * prior to gpg 1.0.4 by assuming that case 3 is a normal + * signature (where file2 is ignored and require for a detached + * signature to indicate signed material comes from stdin by using + * case 4 with a file2 of "-". + * + * Actually we don't have to change anything here but can handle + * that all quite easily in mainproc.c + */ + + sigfile = nfiles? *files : NULL; /* open the signature file */ |