aboutsummaryrefslogtreecommitdiffstats
path: root/sm/gpgsm.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-10-23 08:40:36 +0000
committerWerner Koch <[email protected]>2024-10-23 09:43:08 +0000
commit18081e2ecf43de2be6ad5a7ca3384e1e2b66914d (patch)
tree85aa3365b947da5bc7da0cea5610a60da6517eb3 /sm/gpgsm.c
parentagent: Fix resource leak for PRIMARY_CTX. (diff)
downloadgnupg-18081e2ecf43de2be6ad5a7ca3384e1e2b66914d.tar.gz
gnupg-18081e2ecf43de2be6ad5a7ca3384e1e2b66914d.zip
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
Diffstat (limited to 'sm/gpgsm.c')
-rw-r--r--sm/gpgsm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 26b05773c..bea0184e3 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -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)
{