From 2003a6950166d8e470d71e4e07ef9bbf4bc35ccd Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 17 Oct 2000 02:38:18 +0000 Subject: Don't free 'resp' as it doesn't point to the beginning of the allocated 2000-10-16 Jeffrey Stedfast * providers/imap/camel-imap-command.c (camel_imap_response_extract): Don't free 'resp' as it doesn't point to the beginning of the allocated data, instead free response->untagged->pdata[i]. Also, if '*resp' is equal to a space character, then set resp = imap_next_word (resp) rather than expecting resp++ to work (there's a list broken IMAP daemons that like to put extra spaces between tokens). (imap_read_response): Don't expect 'respbuf+2' to be where the untagged number response to start (see above fix for an explanation). svn path=/trunk/; revision=5960 --- camel/providers/imap/camel-imap-command.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'camel/providers/imap') diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index 7a6045d16d..1827869c14 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -134,7 +134,7 @@ imap_read_response (CamelImapStore *store, CamelException *ex) CamelImapResponse *response; int number, exists = 0; GArray *expunged = NULL; - char *respbuf, *retcode, *p; + char *respbuf, *retcode, *word, *p; /* Read first line */ if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), @@ -154,14 +154,15 @@ imap_read_response (CamelImapStore *store, CamelException *ex) /* If it starts with a number, we might deal with * it ourselves. */ - number = strtoul (respbuf + 2, &p, 10); - if (p != respbuf + 2 && store->current_folder) { - p = imap_next_word (p); - if (!g_strcasecmp (p, "EXISTS")) { + word = imap_next_word (respbuf + 2); + number = strtoul (word, &p, 10); + if (p != word && store->current_folder) { + word = imap_next_word (p); + if (!g_strcasecmp (word, "EXISTS")) { exists = number; g_free (respbuf); goto next; - } else if (!g_strcasecmp (p, "EXPUNGE")) { + } else if (!g_strcasecmp (word, "EXPUNGE")) { if (!expunged) { expunged = g_array_new (FALSE, FALSE, sizeof (int)); @@ -171,8 +172,7 @@ imap_read_response (CamelImapStore *store, CamelException *ex) goto next; } } else { - p = imap_next_word (respbuf); - if (!g_strncasecmp (p, "BYE", 3)) { + if (!g_strncasecmp (word, "BYE", 3)) { /* connection was lost, no more data to fetch */ store->connected = FALSE; g_free (respbuf); @@ -349,11 +349,12 @@ camel_imap_response_extract (CamelImapResponse *response, const char *type, /* Skip "* ", and initial sequence number, if present */ strtoul (resp + 2, &resp, 10); if (*resp == ' ') - resp++; + resp = imap_next_word (resp); if (!g_strncasecmp (resp, type, len)) break; - g_free (resp); + + g_free (response->untagged->pdata[i]); } if (i < response->untagged->len) { -- cgit v1.2.3