From 64c19759bfa6820bd67b47d659ea7241f2efbd9b Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 9 Nov 2001 00:41:09 +0000 Subject: Now takes a command-length argument so we can 1) avoid duping the command 2001-11-06 Jeffrey Stedfast * providers/imap/camel-imap-command.c (camel_imap_command_continuation): Now takes a command-length argument so we can 1) avoid duping the command string yet again, yay. 2) we now don't have to worry about embedded nul-chars screwing us over (we still need to avoid allowing them into the string but at least now it won't mess us up). * providers/imap/camel-imap-folder.c (do_append): Instead of appending a nul char to the end of the byte array and then passing that off as if it were a string to camel_imap_command_continuation, instead pass the byte-array length since that function now takes a length argument. Yay. Also encode any 8bit parts to avoid the possibility of sending embedded nul chars to the imap server. * providers/imap/camel-imap-store.c (try_auth): Updated to pass a command-length argument to camel_imap_command_continuation(). svn path=/trunk/; revision=14637 --- camel/providers/imap/camel-imap-store.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'camel/providers/imap/camel-imap-store.c') diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 1ef9b6edad..0811061280 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -446,31 +446,30 @@ try_auth (CamelImapStore *store, const char *mech, CamelException *ex) CamelImapResponse *response; char *resp; char *sasl_resp; - + CAMEL_IMAP_STORE_ASSERT_LOCKED (store, command_lock); - - response = camel_imap_command (store, NULL, ex, - "AUTHENTICATE %s", mech); + + response = camel_imap_command (store, NULL, ex, "AUTHENTICATE %s", mech); if (!response) return FALSE; - + sasl = camel_sasl_new ("imap", mech, CAMEL_SERVICE (store)); while (!camel_sasl_authenticated (sasl)) { resp = camel_imap_response_extract_continuation (store, response, ex); if (!resp) goto lose; - + sasl_resp = camel_sasl_challenge_base64 (sasl, resp + 2, ex); g_free (resp); if (camel_exception_is_set (ex)) goto break_and_lose; - - response = camel_imap_command_continuation (store, sasl_resp, ex); + + response = camel_imap_command_continuation (store, sasl_resp, strlen (sasl_resp), ex); g_free (sasl_resp); if (!response) goto lose; } - + resp = camel_imap_response_extract_continuation (store, response, NULL); if (resp) { /* Oops. SASL claims we're done, but the IMAP server @@ -483,13 +482,13 @@ try_auth (CamelImapStore *store, const char *mech, CamelException *ex) camel_object_unref (CAMEL_OBJECT (sasl)); return TRUE; - + break_and_lose: /* Get the server out of "waiting for continuation data" mode. */ - response = camel_imap_command_continuation (store, "*", NULL); + response = camel_imap_command_continuation (store, "*", 1, NULL); if (response) camel_imap_response_free (store, response); - + lose: if (!camel_exception_is_set (ex)) { camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, -- cgit v1.2.3