mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gpgsm: Terminate key listing on output write error.
* sm/keylist.c (list_internal_keys): Detect write errors to the output stream. * sm/server.c (any_failure_printed): New var. (gpgsm_status2): Handle new var. Move statusfp init to ... (gpgsm_init_statusfp): new function. (gpgsm_exit_failure_status): New. * sm/gpgsm.c (main): Explicit statusfp init. (gpgsm_exit): Print failure status on error. -- Test by using gpgsm -k >/dev/full gpgsm -k --wit-colons >/dev/full and also by redirecting to a file on a small partition. GnuPG-bug-id: 6185
This commit is contained in:
parent
40707c8bff
commit
18081e2ecf
4 changed files with 74 additions and 15 deletions
15
sm/keylist.c
15
sm/keylist.c
|
@ -1663,6 +1663,7 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
|
|||
|
||||
resname = keydb_get_resource_name (hd);
|
||||
|
||||
es_clearerr (fp);
|
||||
if (lastresname != resname )
|
||||
{
|
||||
int i;
|
||||
|
@ -1716,6 +1717,20 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
|
|||
ksba_cert_release (lastcert);
|
||||
lastcert = cert;
|
||||
cert = NULL;
|
||||
|
||||
if (es_ferror (fp))
|
||||
rc = gpg_error_from_syserror ();
|
||||
|
||||
/* For faster key listings we flush the output after each cert
|
||||
* only if we list secret keys. */
|
||||
if ((mode & 2) && es_fflush (fp) && !rc)
|
||||
rc = gpg_error_from_syserror ();
|
||||
|
||||
if (rc)
|
||||
{
|
||||
log_error (_("error writing to output: %s\n"), gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
|
||||
rc = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue