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-command.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'camel/providers/imap/camel-imap-command.c') diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index 5dd4206841..5639741a42 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -198,6 +198,7 @@ imap_command_start (CamelImapStore *store, CamelFolder *folder, * camel_imap_command_continuation: * @store: the IMAP store * @cmd: buffer containing the response/request data + * @cmdlen: command length * @ex: a CamelException * * This method is for sending continuing responses to the IMAP server @@ -211,10 +212,24 @@ imap_command_start (CamelImapStore *store, CamelFolder *folder, **/ CamelImapResponse * camel_imap_command_continuation (CamelImapStore *store, const char *cmd, - CamelException *ex) + size_t cmdlen, CamelException *ex) { - if (camel_remote_store_send_string (CAMEL_REMOTE_STORE (store), ex, - "%s\r\n", cmd) < 0) { + CamelStream *stream; + + if (!camel_remote_store_connected (CAMEL_REMOTE_STORE (store), ex)) + return NULL; + + stream = CAMEL_REMOTE_STORE (store)->ostream; + + if (camel_stream_write (stream, cmd, cmdlen) == -1 || + camel_stream_write (stream, "\r\n", 2) == -1) { + if (errno == EINTR) + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, + _("Operation cancelled")); + else + camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + g_strerror (errno)); + camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return NULL; } -- cgit v1.2.3