changeset 12581:9db6762167fb

imapc: Fixed sending non-syncing literals.
author Timo Sirainen <tss@iki.fi>
date Wed, 19 Jan 2011 01:20:48 +0200
parents 7dd1e45721ae
children 3949d0091a44
files src/lib-storage/index/imapc/imapc-connection.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-connection.c	Sun Jan 16 18:08:23 2011 +0200
+++ b/src/lib-storage/index/imapc/imapc-connection.c	Wed Jan 19 01:20:48 2011 +0200
@@ -821,7 +821,7 @@
 				    struct imapc_command *cmd)
 {
 	const unsigned char *p;
-	unsigned int seek_pos, end_pos, size;
+	unsigned int seek_pos, start_pos, end_pos, size;
 
 	i_assert(cmd->send_pos < cmd->data->used);
 
@@ -835,11 +835,18 @@
 		}
 	}
 
-	p = memchr(CONST_PTR_OFFSET(cmd->data->data, seek_pos), '\n',
-		   cmd->data->used - seek_pos);
-	i_assert(p != NULL);
+	do {
+		start_pos = seek_pos;
+		p = memchr(CONST_PTR_OFFSET(cmd->data->data, seek_pos), '\n',
+			   cmd->data->used - seek_pos);
+		i_assert(p != NULL);
 
-	end_pos = p - (const unsigned char *)cmd->data->data + 1;
+		seek_pos = p - (const unsigned char *)cmd->data->data + 1;
+		/* keep going for LITERAL+ command */
+	} while (start_pos + 3 < seek_pos &&
+		 p[-1] == '\r' && p[-2] == '}' && p[-3] == '+');
+	end_pos = seek_pos;
+
 	o_stream_send(conn->output,
 		      CONST_PTR_OFFSET(cmd->data->data, cmd->send_pos),
 		      end_pos - cmd->send_pos);