1
0
Fork 0
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:
Werner Koch 2024-10-23 10:40:36 +02:00
parent 40707c8bff
commit 18081e2ecf
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
4 changed files with 74 additions and 15 deletions

View file

@ -1803,6 +1803,10 @@ main ( int argc, char **argv)
gnupg_inhibit_set_foregound_window (1);
}
/* Better make sure that we have a statusfp so that a failure status
* in gpgsm_exit can work even w/o any preeding status messages. */
gpgsm_init_statusfp (&ctrl);
/* Add default keybox. */
if (!nrings && default_keyring && !opt.use_keyboxd)
{
@ -2356,6 +2360,12 @@ gpgsm_exit (int rc)
else if (opt.assert_signer_list && !assert_signer_true)
rc = 1;
/* If we had an error but not printed an error message, do it now.
* Note that the function will never print a second failure status
* line. */
if (rc)
gpgsm_exit_failure_status ();
gcry_control (GCRYCTL_UPDATE_RANDOM_SEED_FILE);
if (opt.debug & DBG_MEMSTAT_VALUE)
{