From 97a56fd84af16acbcd6722dd2b7a3c9caf941cfa Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 2 Nov 2004 18:56:53 +0000 Subject: Do proper cleanup in case of error and also handle literals. 2004-11-02 Jeffrey Stedfast * providers/imap4/camel-imap4-summary.c (envelope_decode_address): Do proper cleanup in case of error and also handle literals. svn path=/trunk/; revision=27798 --- camel/ChangeLog | 12 +++++++--- camel/providers/imap4/camel-imap4-summary.c | 37 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 9 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index e0ce439045..01c00dc096 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,8 @@ 2004-11-02 Jeffrey Stedfast + * providers/imap4/camel-imap4-summary.c (envelope_decode_address): + Do proper cleanup in case of error and also handle literals. + * providers/imap4/camel-imap4-store.c (imap4_get_folder_info): Removed camel_service_connect() call which is no longer needed. (imap4_connect): If engine is already connected, shortcut to @@ -13,11 +16,14 @@ (connect_to_server_wrapper): Do the same SSL->TLS and TLS->CLEAR fallbacks that the 2.0 (and older) code did. - * providers/pop3/camel-pop3-store.c (connect_to_server_wrapper): Same. + * providers/pop3/camel-pop3-store.c (connect_to_server_wrapper): + Same. - * providers/imap4/camel-imap4-store.c (connect_to_server_wrapper): Same. + * providers/imap4/camel-imap4-store.c (connect_to_server_wrapper): + Same. - * providers/imap/camel-imap-store.c (connect_to_server_wrapper): Same. + * providers/imap/camel-imap-store.c (connect_to_server_wrapper): + Same. 2004-11-01 Jeffrey Stedfast diff --git a/camel/providers/imap4/camel-imap4-summary.c b/camel/providers/imap4/camel-imap4-summary.c index 2ed1e490da..d1d581d690 100644 --- a/camel/providers/imap4/camel-imap4-summary.c +++ b/camel/providers/imap4/camel-imap4-summary.c @@ -163,9 +163,11 @@ envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelExceptio { char *addr, *name = NULL, *user = NULL; struct _camel_header_address *cia; + unsigned char *literal = NULL; camel_imap4_token_t token; const char *domain = NULL; int part = 0; + size_t n; if (camel_imap4_engine_next_token (engine, &token, ex) == -1) return -1; @@ -182,8 +184,9 @@ envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelExceptio do { if (camel_imap4_engine_next_token (engine, &token, ex) == -1) - return -1; + goto exception; + literal = NULL; switch (token.token) { case CAMEL_IMAP4_TOKEN_NIL: break; @@ -201,17 +204,33 @@ envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelExceptio break; } break; + case CAMEL_IMAP4_TOKEN_LITERAL: + if (camel_imap4_engine_literal (engine, &literal, &n, ex) == -1) + goto exception; + + switch (part) { + case 0: + name = camel_header_decode_string (literal, NULL); + g_free (literal); + break; + case 2: + user = literal; + break; + case 3: + domain = literal; + break; + } + break; default: camel_imap4_utils_set_unexpected_token_error (ex, engine, &token); - g_free (name); - g_free (user); - return -1; + goto exception; } part++; } while (part < 4); addr = g_strdup_printf ("%s@%s", user, domain); + g_free (literal); g_free (user); cia = camel_header_address_new_name (name, addr); @@ -233,6 +252,13 @@ envelope_decode_address (CamelIMAP4Engine *engine, GString *addrs, CamelExceptio } return 0; + + exception: + + g_free (name); + g_free (user); + + return -1; } static int @@ -315,8 +341,7 @@ envelope_decode_date (CamelIMAP4Engine *engine, time_t *date, CamelException *ex *date = camel_header_decode_date (nstring, NULL); - if (literal) - g_free (literal); + g_free (literal); return 0; } -- cgit