changeset 5409:b9580d02084b HEAD

Don't read/write outside boundaries if the extension data's size isn't divisible with 32bit.
author Timo Sirainen <tss@iki.fi>
date Sun, 25 Mar 2007 21:25:50 +0300
parents 2847c8f771a8
children 73032525bca0
files src/lib-index/mail-index-transaction.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction.c	Sun Mar 25 21:24:22 2007 +0300
+++ b/src/lib-index/mail-index-transaction.c	Sun Mar 25 21:25:50 2007 +0300
@@ -122,16 +122,17 @@
 				     void *old_record)
 {
 	void *p;
-	unsigned int idx;
+	unsigned int idx, aligned_record_size;
 
 	/* records need to be 32bit aligned */
-	record_size = (record_size + 3) & ~3;
+	aligned_record_size = (record_size + 3) & ~3;
 
 	if (!array_is_created(array)) {
-		array_create(array, default_pool, sizeof(seq) + record_size,
-			     1024 / (sizeof(seq) + record_size));
+		array_create(array, default_pool,
+			     sizeof(seq) + aligned_record_size,
+			     1024 / (sizeof(seq) + aligned_record_size));
 	}
-	i_assert(array->arr.element_size == sizeof(seq) + record_size);
+	i_assert(array->arr.element_size == sizeof(seq) + aligned_record_size);
 
 	if (mail_index_seq_array_lookup(array, seq, &idx)) {
 		/* already there, update */