mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
sm: Try not to output a partial new message after an error.
* sm/gpgsm.c (main) <aSign,aEncr>: Uses gpgrt_fcancel on error. -- When creating a signature or encrypting and the respective key is not available or the user canceled the PIN entry gpgsm prints the initial part of the message due to internal buffering in gpgrt. By using gpgrt_fcancel we can avoid this at least as long as the data is less than the standard buffer size (which is currently 8k). If is not a complete solution but the best we can do easily. Outputting to the tty is anyway more of a testing aid than for real use. This makes use of the new gpgrt_fcancel API. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
208a901973
commit
ccbb0cfeef
21
sm/gpgsm.c
21
sm/gpgsm.c
@ -953,6 +953,7 @@ parse_keyserver_line (char *line,
|
||||
int
|
||||
main ( int argc, char **argv)
|
||||
{
|
||||
gpg_error_t err;
|
||||
gpgrt_argparse_t pargs;
|
||||
int orig_argc;
|
||||
char **orig_argv;
|
||||
@ -1929,7 +1930,15 @@ main ( int argc, char **argv)
|
||||
else
|
||||
wrong_args ("--encrypt [datafile]");
|
||||
|
||||
#if GPGRT_VERSION_NUMBER >= 0x012700 /* >= 1.39 */
|
||||
if (err)
|
||||
gpgrt_fcancel (fp);
|
||||
else
|
||||
es_fclose (fp);
|
||||
#else
|
||||
(void)err;
|
||||
es_fclose (fp);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1941,14 +1950,22 @@ main ( int argc, char **argv)
|
||||
signing because that is what gpg does.*/
|
||||
set_binary (stdin);
|
||||
if (!argc) /* Create from stdin. */
|
||||
gpgsm_sign (&ctrl, signerlist, 0, detached_sig, fp);
|
||||
err = gpgsm_sign (&ctrl, signerlist, 0, detached_sig, fp);
|
||||
else if (argc == 1) /* From file. */
|
||||
gpgsm_sign (&ctrl, signerlist,
|
||||
err = gpgsm_sign (&ctrl, signerlist,
|
||||
open_read (*argv), detached_sig, fp);
|
||||
else
|
||||
wrong_args ("--sign [datafile]");
|
||||
|
||||
#if GPGRT_VERSION_NUMBER >= 0x012700 /* >= 1.39 */
|
||||
if (err)
|
||||
gpgrt_fcancel (fp);
|
||||
else
|
||||
es_fclose (fp);
|
||||
#else
|
||||
(void)err;
|
||||
es_fclose (fp);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user