# HG changeset patch # User Timo Sirainen # Date 1174847150 -10800 # Node ID b9580d02084b2f72a327e6e9ffc32ac6e456409b # Parent 2847c8f771a8f6c4a5c766a850bbb540c975dddc Don't read/write outside boundaries if the extension data's size isn't divisible with 32bit. diff -r 2847c8f771a8 -r b9580d02084b src/lib-index/mail-index-transaction.c --- 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 */