[evolution-data-server/gnome-3-16] [IMAPx] Ignore broken (truncated) COPYUID server response
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-16] [IMAPx] Ignore broken (truncated) COPYUID server response
- Date: Fri, 7 Aug 2015 05:27:01 +0000 (UTC)
commit ec638953e89f706a347e1fde0716640edbb6eaff
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 7 07:26:59 2015 +0200
[IMAPx] Ignore broken (truncated) COPYUID server response
camel/providers/imapx/camel-imapx-input-stream.c | 3 ++
camel/providers/imapx/camel-imapx-utils.c | 36 +++++++++++++++++++--
2 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-input-stream.c
b/camel/providers/imapx/camel-imapx-input-stream.c
index 6a0af1e..c7d20e9 100644
--- a/camel/providers/imapx/camel-imapx-input-stream.c
+++ b/camel/providers/imapx/camel-imapx-input-stream.c
@@ -707,6 +707,9 @@ camel_imapx_input_stream_token (CamelIMAPXInputStream *is,
return is->priv->unget_tok;
}
+ *data = NULL;
+ *len = 0;
+
if (is->priv->literal > 0)
g_warning (
"stream_token called with literal %d",
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 956b22b..c63de65 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -2101,7 +2101,7 @@ imapx_parse_uids (CamelIMAPXInputStream *stream,
GError **error)
{
GArray *array;
- guchar *token;
+ guchar *token = NULL;
gchar **splits;
guint len, str_len;
gint tok, ii;
@@ -2113,6 +2113,11 @@ imapx_parse_uids (CamelIMAPXInputStream *stream,
if (tok < 0)
return NULL;
+ if (!token) {
+ g_set_error (error, CAMEL_IMAPX_ERROR, 2, "server response truncated");
+ return NULL;
+ }
+
array = g_array_new (FALSE, FALSE, sizeof (guint32));
splits = g_strsplit ((gchar *) token, ",", -1);
str_len = g_strv_length (splits);
@@ -2188,6 +2193,7 @@ imapx_parse_status_copyuid (CamelIMAPXInputStream *stream,
GArray *uids;
guint64 number;
gboolean success;
+ GError *local_error = NULL;
success = camel_imapx_input_stream_number (
stream, &number, cancellable, error);
@@ -2197,15 +2203,37 @@ imapx_parse_status_copyuid (CamelIMAPXInputStream *stream,
sinfo->u.copyuid.uidvalidity = number;
- uids = imapx_parse_uids (stream, cancellable, error);
- if (uids == NULL)
+ uids = imapx_parse_uids (stream, cancellable, &local_error);
+ if (uids == NULL) {
+ /* Some broken servers can return truncated response, like:
+ B00083 OK [COPYUID 4154 ] COPY completed.
+ Just ignore such server error.
+ */
+ if (g_error_matches (local_error, CAMEL_IMAPX_ERROR, 2)) {
+ g_clear_error (&local_error);
+ return TRUE;
+ }
+
+ if (local_error)
+ g_propagate_error (error, local_error);
+
return FALSE;
+ }
sinfo->u.copyuid.uids = uids;
uids = imapx_parse_uids (stream, cancellable, error);
- if (uids == NULL)
+ if (uids == NULL) {
+ if (g_error_matches (local_error, CAMEL_IMAPX_ERROR, 2)) {
+ g_clear_error (&local_error);
+ return TRUE;
+ }
+
+ if (local_error)
+ g_propagate_error (error, local_error);
+
return FALSE;
+ }
sinfo->u.copyuid.copied_uids = uids;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]