[evolution-data-server/gnome-3-8] Bug #698261 - Skip invalid flags in imapx_parse_flags()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-8] Bug #698261 - Skip invalid flags in imapx_parse_flags()
- Date: Thu, 18 Apr 2013 12:16:43 +0000 (UTC)
commit d9a7ecf244177fa5afc94a070b46ba27a9e7ea37
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 18 14:16:15 2013 +0200
Bug #698261 - Skip invalid flags in imapx_parse_flags()
Previous patch had incorrectly implemented skip of the broken flag,
which fixes this change.
camel/camel-imapx-stream.c | 39 +++++++++++++++++++++++++++++++++++++++
camel/camel-imapx-stream.h | 5 +++++
camel/camel-imapx-utils.c | 15 ++-------------
3 files changed, 46 insertions(+), 13 deletions(-)
---
diff --git a/camel/camel-imapx-stream.c b/camel/camel-imapx-stream.c
index 9b60568..7d0a7cd 100644
--- a/camel/camel-imapx-stream.c
+++ b/camel/camel-imapx-stream.c
@@ -948,3 +948,42 @@ camel_imapx_stream_skip (CamelIMAPXStream *is,
return 0;
}
+gboolean
+camel_imapx_stream_skip_until (CamelIMAPXStream *is,
+ const gchar *delimiters,
+ GCancellable *cancellable,
+ GError **error)
+{
+ register guchar c;
+ guchar *p, *e;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (is), FALSE);
+
+ if (is->priv->unget > 0) {
+ is->priv->unget--;
+ return TRUE;
+ }
+
+ if (is->priv->literal > 0) {
+ is->priv->literal--;
+ return TRUE;
+ }
+
+ p = is->priv->ptr;
+ e = is->priv->end;
+
+ do {
+ while (p >= e ) {
+ is->priv->ptr = p;
+ if (imapx_stream_fill (is, cancellable, error) == IMAPX_TOK_ERROR)
+ return FALSE;
+ p = is->priv->ptr;
+ e = is->priv->end;
+ }
+ c = *p++;
+ } while (c && c != ' ' && c != '\r' && c != '\n' && (!delimiters || !strchr (delimiters, c)));
+
+ is->priv->ptr = p;
+
+ return TRUE;
+}
diff --git a/camel/camel-imapx-stream.h b/camel/camel-imapx-stream.h
index a3b650a..9664288 100644
--- a/camel/camel-imapx-stream.h
+++ b/camel/camel-imapx-stream.h
@@ -145,6 +145,11 @@ gint camel_imapx_stream_skip (CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
+gboolean camel_imapx_stream_skip_until (CamelIMAPXStream *is,
+ const gchar *delimiters,
+ GCancellable *cancellable,
+ GError **error);
+
G_END_DECLS
#endif /* CAMEL_IMAPX_STREAM_H */
diff --git a/camel/camel-imapx-utils.c b/camel/camel-imapx-utils.c
index 0845618..4007fbc 100644
--- a/camel/camel-imapx-utils.c
+++ b/camel/camel-imapx-utils.c
@@ -134,19 +134,8 @@ imapx_parse_flags (CamelIMAPXStream *stream,
found:
g_free (upper);
} else if (tok != ')') {
- 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;
- }
- }
+ if (!camel_imapx_stream_skip_until (stream, ")", cancellable, NULL))
+ break;
}
} while (tok != ')' && tok > 0);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]