dovecot-1.2: mail_index_update_header_ext(): Don't crash if size...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 18 06:33:43 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/053d1aa325f6
changeset: 7892:053d1aa325f6
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 18 06:33:08 2008 +0300
description:
mail_index_update_header_ext(): Don't crash if size isn't 32bit aligned.

diffstat:

1 file changed, 3 insertions(+), 1 deletion(-)
src/lib-index/mail-transaction-log-append.c |    4 +++-

diffs (19 lines):

diff -r 9cd7caa922d6 -r 053d1aa325f6 src/lib-index/mail-transaction-log-append.c
--- a/src/lib-index/mail-transaction-log-append.c	Wed Jun 18 06:30:51 2008 +0300
+++ b/src/lib-index/mail-transaction-log-append.c	Wed Jun 18 06:33:08 2008 +0300
@@ -294,12 +294,14 @@ log_append_ext_hdr_update(struct log_app
 	buffer_t *buf;
 	unsigned int hdr_size;
 
-	hdr_size = sizeof(*trans_hdr) + hdr->size;
+	hdr_size = sizeof(*trans_hdr) + hdr->size + 4;
 	buf = buffer_create_static_hard(pool_datastack_create(), hdr_size);
 	trans_hdr = buffer_append_space_unsafe(buf, sizeof(*trans_hdr));
 	trans_hdr->offset = hdr->offset;
 	trans_hdr->size = hdr->size;
 	buffer_append(buf, hdr + 1, hdr->size);
+	if (buf->used % 4 != 0)
+		buffer_append_zero(buf, 4 - buf->used % 4);
 	log_append_buffer(ctx, buf, NULL, MAIL_TRANSACTION_EXT_HDR_UPDATE);
 }
 


More information about the dovecot-cvs mailing list