Commit 66d1467a authored by Peter Jeremy's avatar Peter Jeremy Committed by Richard P. Curnow

Fix SEGV if mbox shrinks

If you build the database using mbox files and then shrink one of the files (eg
delete a message out of it) then mairix will SEGV if it tries to search that
file.
parent de97866f
......@@ -716,7 +716,15 @@ static void get_validated_mbox_msg(struct read_db *db, int msg_index,/*{{{*/
if (!*mbox_data) return;
start = *mbox_data + db->mtime_table[msg_index];
*msg_len = db->size_table[msg_index];
/* Ensure that we don't run off the end of the mmap'd file */
if (db->mtime_table[msg_index] >= *mbox_len)
*msg_len = 0;
else if (db->mtime_table[msg_index] + db->size_table[msg_index] >= *mbox_len)
*msg_len = *mbox_len - db->mtime_table[msg_index];
else
*msg_len = db->size_table[msg_index];
compute_checksum((char *)start, *msg_len, &csum);
if (!memcmp((db->data + db->mbox_checksum_table[mbi] + (msgi * sizeof(checksum_t))), &csum, sizeof(checksum_t))) {
*msg_data = start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment