[evolution-data-server] [IMAPx] Cancel authentication request when failed to get the SASL response



commit 326a7f096e74c03c71a75aa81994736f0a81dd58
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 22 15:01:19 2021 +0100

    [IMAPx] Cancel authentication request when failed to get the SASL response
    
    The connection could be left in an inconsistent state when the authentication
    request had been interrupted due to the SASL response failed. To get
    the connection to the correct state cancel the AUTHENTICATE command.

 src/camel/providers/imapx/camel-imapx-server.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 63a26f70d..060b1274b 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -2326,8 +2326,22 @@ imapx_continuation (CamelIMAPXServer *is,
                        (CamelSasl *) cp->ob, (const gchar *) token,
                        cancellable, error);
                g_free (token);
-               if (resp == NULL)
+               if (resp == NULL) {
+                       /* Cancel the request */
+                       g_mutex_lock (&is->priv->stream_lock);
+                       n_bytes_written = g_output_stream_write_all (
+                               output_stream, "*\r\n", 3,
+                               NULL, cancellable, NULL);
+                       if (n_bytes_written == 3)
+                               g_output_stream_flush (output_stream, cancellable, NULL);
+                       g_mutex_unlock (&is->priv->stream_lock);
+
+                       camel_imapx_input_stream_skip (
+                               CAMEL_IMAPX_INPUT_STREAM (input_stream),
+                               cancellable, NULL);
+
                        return FALSE;
+               }
                c (is->priv->tagprefix, "got auth continuation, feeding token '%s' back to auth mech\n", 
resp);
 
                g_mutex_lock (&is->priv->stream_lock);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]