aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2023-07-21 05:18:33 +0000
committerNIIBE Yutaka <[email protected]>2023-07-21 05:22:19 +0000
commiteceba4f20749f936c4e787116aa5323dc95abaa5 (patch)
tree4719531af670c58e91416866d6ef5173f42a1eaa
parentdirmngr: Add doc for faked-system-time (diff)
downloadgnupg-eceba4f20749f936c4e787116aa5323dc95abaa5.tar.gz
gnupg-eceba4f20749f936c4e787116aa5323dc95abaa5.zip
kbx: Fix error paths to fall back to D-lines.
* kbx/kbx-client-util.c (prepare_data_pipe): Return an error. (kbx_client_data_new): Recover from an error by use of D-lines. (kbx_client_data_release): Handle the case of use of D-lines. -- Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--kbx/kbx-client-util.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/kbx/kbx-client-util.c b/kbx/kbx-client-util.c
index 8cd6dc0f3..2ea3f5ef7 100644
--- a/kbx/kbx-client-util.c
+++ b/kbx/kbx-client-util.c
@@ -129,7 +129,7 @@ prepare_data_pipe (kbx_client_data_t kcd)
inpipe[1], gpg_strerror (err), gpg_strsource (err));
es_fclose (infp);
gnupg_close_pipe (inpipe[1]);
- return 0; /* Server may not support fd-passing. */
+ return err;
}
err = assuan_transact (kcd->ctx, "OUTPUT FD",
@@ -139,13 +139,12 @@ prepare_data_pipe (kbx_client_data_t kcd)
log_info ("keyboxd does not accept our fd: %s <%s>\n",
gpg_strerror (err), gpg_strsource (err));
es_fclose (infp);
- return 0;
+ return err;
}
close (inpipe[1]);
kcd->fp = infp;
-
rc = npth_attr_init (&tattr);
if (rc)
{
@@ -295,8 +294,7 @@ kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx,
{
err = gpg_error_from_errno (rc);
log_error ("error initializing mutex: %s\n", gpg_strerror (err));
- xfree (kcd);
- return err;
+ goto leave; /* Use D-lines. */
}
rc = npth_cond_init (&kcd->cond, NULL);
if (rc)
@@ -304,8 +302,7 @@ kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx,
err = gpg_error_from_errno (rc);
log_error ("error initializing condition: %s\n", gpg_strerror (err));
npth_mutex_destroy (&kcd->mutex);
- xfree (kcd);
- return err;
+ goto leave; /* Use D-lines. */
}
err = prepare_data_pipe (kcd);
@@ -313,8 +310,7 @@ kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx,
{
npth_cond_destroy (&kcd->cond);
npth_mutex_destroy (&kcd->mutex);
- xfree (kcd);
- return err;
+ /* Use D-lines. */
}
leave:
@@ -331,10 +327,16 @@ kbx_client_data_release (kbx_client_data_t kcd)
if (!kcd)
return;
+ fp = kcd->fp;
+ if (!fp)
+ {
+ xfree (kcd);
+ return;
+ }
+
if (npth_join (kcd->thd, NULL))
log_error ("kbx_client_data_release failed on npth_join");
- fp = kcd->fp;
kcd->fp = NULL;
es_fclose (fp);