[dovecot-cvs] dovecot/src/lib-mail istream-header-filter.c, 1.18, 1.19 message-body-search.c, 1.18, 1.19 message-parser.c, 1.63, 1.64 quoted-printable.c, 1.5, 1.6

cras at dovecot.org cras at dovecot.org
Fri Oct 8 20:51:51 EEST 2004


Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv10130/lib-mail

Modified Files:
	istream-header-filter.c message-body-search.c message-parser.c 
	quoted-printable.c 
Log Message:
Buffer API change: we no longer support limited sized buffers where
writes past limit wouldn't kill the process. They weren't used hardly
anywhere, they could have hidden bugs and the code for handling them was too
complex.

This also changed base64 and hex-binary APIs.



Index: istream-header-filter.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/istream-header-filter.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- istream-header-filter.c	11 Sep 2004 19:58:38 -0000	1.18
+++ istream-header-filter.c	8 Oct 2004 17:51:48 -0000	1.19
@@ -291,7 +291,7 @@
 	for (i = 0; i < headers_count; i++) 
 		mstream->headers[i] = p_strdup(pool, headers[i]);
 	mstream->headers_count = headers_count;
-	mstream->hdr_buf = buffer_create_dynamic(pool, 1024, (size_t)-1);
+	mstream->hdr_buf = buffer_create_dynamic(pool, 1024);
 
 	mstream->callback = callback;
 	mstream->context = context;

Index: message-body-search.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-body-search.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- message-body-search.c	22 Aug 2004 03:19:58 -0000	1.18
+++ message-body-search.c	8 Oct 2004 17:51:48 -0000	1.19
@@ -213,10 +213,10 @@
 	const unsigned char *inbuf;
 	buffer_t *outbuf;
         enum charset_result result;
-	size_t block_pos, inbuf_size, inbuf_left, ret;
+	size_t block_pos, inbuf_size, inbuf_left;
 
-	outbuf = buffer_create_static(pool_datastack_create(),
-				      DECODE_BLOCK_SIZE);
+	outbuf = buffer_create_static_hard(pool_datastack_create(),
+					   DECODE_BLOCK_SIZE);
 	for (block_pos = 0; block_pos < buffer_get_used_size(block); ) {
 		if (buffer_get_used_size(ctx->decode_buf) == 0) {
 			/* we can use the buffer directly without copying */
@@ -226,9 +226,9 @@
 		} else {
 			/* some characters already in buffer, ie. last
 			   conversion contained partial data */
-			block_pos += buffer_append_buf(ctx->decode_buf,
-						       block, block_pos,
-						       (size_t)-1);
+			buffer_append_buf(ctx->decode_buf, block,
+					  block_pos, block->used);
+                        block_pos += block->used;
 
 			inbuf = buffer_get_data(ctx->decode_buf, &inbuf_size);
 		}
@@ -250,11 +250,9 @@
 			break;
 		case CHARSET_RET_INCOMPLETE_INPUT:
 			/* save the partial sequence to buffer */
-			ret = buffer_write(ctx->decode_buf, 0,
-					   inbuf + inbuf_size, inbuf_left);
-			i_assert(ret == inbuf_left);
-
-			buffer_set_used_size(ctx->decode_buf, ret);
+			buffer_write(ctx->decode_buf, 0,
+				     inbuf + inbuf_size, inbuf_left);
+			buffer_set_used_size(ctx->decode_buf, inbuf_left);
 			break;
 
 		case CHARSET_RET_INVALID_INPUT:
@@ -294,7 +292,8 @@
 	if (ctx->translation == NULL)
 		ctx->translation = charset_to_utf8_begin("ascii", NULL);
 
-	ctx->decode_buf = buffer_create_static(pool_datastack_create(), 256);
+	ctx->decode_buf =
+		buffer_create_static_hard(pool_datastack_create(), 256);
 	ctx->match_buf = buffer_create_static_hard(pool_datastack_create(),
 						   sizeof(size_t) *
 						   ctx->body_ctx->key_len);

Index: message-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- message-parser.c	8 Sep 2004 13:58:33 -0000	1.63
+++ message-parser.c	8 Oct 2004 17:51:48 -0000	1.64
@@ -703,7 +703,7 @@
 			else {
 				ctx->value_buf =
 					buffer_create_dynamic(default_pool,
-							      4096, (size_t)-1);
+							      4096);
 			}
 			buffer_append(ctx->value_buf,
 				      line->value, line->value_len);

Index: quoted-printable.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/quoted-printable.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- quoted-printable.c	8 Feb 2003 06:33:30 -0000	1.5
+++ quoted-printable.c	8 Oct 2004 17:51:48 -0000	1.6
@@ -49,7 +49,7 @@
 		hexbuf[0] = src[src_pos+1];
 		hexbuf[1] = src[src_pos+2];
 
-		if (hex_to_binary(hexbuf, dest) == 1) {
+		if (hex_to_binary(hexbuf, dest) == 0) {
 			src_pos += 2;
 			next = src_pos+1;
 		} else {



More information about the dovecot-cvs mailing list