[evolution-data-server/gnome-3-30] I#75 - Sometimes fails to properly decrypt large GPG encrypted messages
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-30] I#75 - Sometimes fails to properly decrypt large GPG encrypted messages
- Date: Mon, 7 Jan 2019 20:05:33 +0000 (UTC)
commit ea992b8b2af6c8bbafa55b618936cd3e4dfa9ca7
Author: Milan Crha <mcrha redhat com>
Date: Mon Jan 7 21:01:03 2019 +0100
I#75 - Sometimes fails to properly decrypt large GPG encrypted messages
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/75
src/camel/camel-gpg-context.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/camel/camel-gpg-context.c b/src/camel/camel-gpg-context.c
index 27214cdd3..64f5fc8d2 100644
--- a/src/camel/camel-gpg-context.c
+++ b/src/camel/camel-gpg-context.c
@@ -1517,11 +1517,35 @@ gpg_ctx_op_step (struct _GpgCtx *gpg,
if (nread > 0) {
if (gpg->mode != GPG_CTX_MODE_DECRYPT ||
gpg->in_decrypt_stage || was_in_decrypt_stage) {
- gsize written = camel_stream_write (
- gpg->ostream, buffer, (gsize)
- nread, cancellable, error);
- if (written != nread)
- return -1;
+ gboolean done = FALSE;
+
+ while (!done) {
+ gsize written = camel_stream_write (
+ gpg->ostream, buffer, (gsize)
+ nread, cancellable, error);
+ if (written != nread)
+ return -1;
+
+ done = TRUE;
+
+ /* Read everything cached */
+ do {
+ polls[0].revents = 0;
+ status = g_poll (polls, 1, 5);
+ } while (status == -1 && errno == EINTR);
+
+ if (status != -1 && status != 0 && (polls[0].revents & (G_IO_IN |
G_IO_HUP))) {
+ do {
+ nread = read (gpg->stdout_fd, buffer, sizeof
(buffer));
+ d (printf (" cached read %d bytes (%.*s)\n", (gint)
nread, (gint) nread, buffer));
+ } while (nread == -1 && (errno == EINTR || errno == EAGAIN));
+
+ if (nread == -1)
+ goto exception;
+
+ done = !nread;
+ }
+ }
} else {
if (!gpg->decrypt_extra_text)
gpg->decrypt_extra_text = g_string_new ("");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]