[evolution-data-server] Bug #698261 - Skip invalid flags in imapx_parse_flags()



commit 7d364ca350a3c0b8868fba82aa80ed39496eea3d
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 18 12:27:16 2013 +0200

    Bug #698261 - Skip invalid flags in imapx_parse_flags()

 camel/camel-imapx-server.c |  7 +++++--
 camel/camel-imapx-utils.c  | 17 ++++++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index 1bd5565..15bfc0a 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -1730,13 +1730,16 @@ imapx_untagged_flags (CamelIMAPXServer *is,
                       GError **error)
 {
        guint32 flags;
+       GError *local_error = NULL;
 
        g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
        /* cancellable may be NULL */
        g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-       imapx_parse_flags (stream, &flags, NULL, cancellable, error);
-       c (is->tagprefix, "flags: %08x\n", flags);
+       imapx_parse_flags (stream, &flags, NULL, cancellable, &local_error);
+       c (is->tagprefix, "flags: %08x %s%s\n", flags, local_error ? "error: " : "", local_error ? 
local_error->message : "");
+
+       g_clear_error (&local_error);
 
        return TRUE;
 }
diff --git a/camel/camel-imapx-utils.c b/camel/camel-imapx-utils.c
index 1431ab6..0845618 100644
--- a/camel/camel-imapx-utils.c
+++ b/camel/camel-imapx-utils.c
@@ -134,10 +134,21 @@ imapx_parse_flags (CamelIMAPXStream *stream,
                        found:
                                g_free (upper);
                        } else if (tok != ')') {
-                               g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting flag");
-                               return;
+                               CamelStream *strm = CAMEL_STREAM (stream);
+                               gssize read;
+
+                               while (tok != ')' && tok != ' ' && tok > 0) {
+                                       gchar chr = 0;
+
+                                       read = camel_stream_read (strm, &chr, 1, cancellable, NULL);
+                                       if (read == 1) {
+                                               tok = chr;
+                                       } else {
+                                               tok = IMAPX_TOK_ERROR;
+                                       }
+                               }
                        }
-               } while (tok != ')');
+               } while (tok != ')' && tok > 0);
        } else {
                g_set_error (error, CAMEL_IMAPX_ERROR, 1, "execting flag list");
                return;


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