aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2025-08-11 05:08:17 +0000
committerNIIBE Yutaka <[email protected]>2025-08-11 05:08:17 +0000
commitf609b195fb3d9f87a45d145af8a0f4057213cdb4 (patch)
tree2625c664bfaa7c686c487cf4c501cd44dcdfb8f5 /src/client.c
parentFix comment. (diff)
downloadlibassuan-master.tar.gz
libassuan-master.zip
Care about the case when data callback is not supplied or failed.HEADmaster
* src/client.c (assuan_transact): Consume the whole data from server when DATA_CB is not supplied or failed. -- GnuPG-bug-id: 7399 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to '')
-rw-r--r--src/client.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/client.c b/src/client.c
index 410f940..e10f67c 100644
--- a/src/client.c
+++ b/src/client.c
@@ -250,6 +250,7 @@ assuan_transact (assuan_context_t ctx,
int off;
char *line;
int linelen;
+ gpg_error_t last_err = 0;
rc = assuan_write_line (ctx, command);
if (rc)
@@ -278,9 +279,12 @@ assuan_transact (assuan_context_t ctx,
rc = data_cb (data_cb_arg, line, linelen);
if (ctx->flags.confidential)
wipememory (ctx->inbound.line, LINELENGTH);
- if (!rc)
- goto again;
}
+ /* We need to consume the whole data from server to avoid
+ unsynched state. */
+ if (rc)
+ last_err = rc;
+ goto again;
}
else if (response == ASSUAN_RESPONSE_INQUIRE)
{
@@ -338,12 +342,16 @@ assuan_transact (assuan_context_t ctx,
if (!data_cb)
rc = _assuan_error (ctx, GPG_ERR_ASS_NO_DATA_CB);
else
- {
- rc = data_cb (data_cb_arg, NULL, 0);
- if (!rc)
- goto again;
- }
+ rc = data_cb (data_cb_arg, NULL, 0);
+ /* We need to finish the response from server to avoid
+ unsynched state. */
+ if (rc)
+ last_err = rc;
+ goto again;
}
+ if (!rc)
+ return last_err;
+
return rc;
}