dovecot: Don't crash if extension record size is 0.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jul 8 20:03:36 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/a4c80b0ee22b
changeset: 5896:a4c80b0ee22b
user: Timo Sirainen <tss at iki.fi>
date: Sun Jul 08 19:45:59 2007 +0300
description:
Don't crash if extension record size is 0.
diffstat:
2 files changed, 7 insertions(+), 4 deletions(-)
src/lib-index/mail-index-map.c | 8 +++++---
src/lib-index/mail-index-sync-ext.c | 3 ++-
diffs (38 lines):
diff -r cb5e25c3b300 -r a4c80b0ee22b src/lib-index/mail-index-map.c
--- a/src/lib-index/mail-index-map.c Sun Jul 08 19:33:18 2007 +0300
+++ b/src/lib-index/mail-index-map.c Sun Jul 08 19:45:59 2007 +0300
@@ -171,7 +171,8 @@ static int mail_index_parse_extensions(s
}
if ((ext_hdr->record_size == 0 && ext_hdr->hdr_size == 0) ||
- ext_hdr->record_align == 0 || *name == '\0') {
+ (ext_hdr->record_align == 0 && ext_hdr->record_size != 0) ||
+ *name == '\0') {
mail_index_set_error(index, "Corrupted index file %s: "
"Broken header extension %s",
index->filepath, *name == '\0' ?
@@ -190,8 +191,9 @@ static int mail_index_parse_extensions(s
return -1;
}
- if ((ext_hdr->record_offset % ext_hdr->record_align) != 0 ||
- (map->hdr.record_size % ext_hdr->record_align) != 0) {
+ if (ext_hdr->record_size > 0 &&
+ ((ext_hdr->record_offset % ext_hdr->record_align) != 0 ||
+ (map->hdr.record_size % ext_hdr->record_align) != 0)) {
mail_index_set_error(index, "Corrupted index file %s: "
"Record field %s alignmentation %u not used",
index->filepath, name, ext_hdr->record_align);
diff -r cb5e25c3b300 -r a4c80b0ee22b src/lib-index/mail-index-sync-ext.c
--- a/src/lib-index/mail-index-sync-ext.c Sun Jul 08 19:33:18 2007 +0300
+++ b/src/lib-index/mail-index-sync-ext.c Sun Jul 08 19:45:59 2007 +0300
@@ -192,7 +192,8 @@ static void sync_ext_reorder(struct mail
if (sorted[i]->record_align > max_align)
max_align = sorted[i]->record_align;
- if (sorted[i]->record_offset == 0) {
+ if (sorted[i]->record_offset == 0 &&
+ sorted[i]->record_size > 0) {
if ((offset % sorted[i]->record_align) == 0)
break;
if (sorted[i]->record_align < min_align)
More information about the dovecot-cvs
mailing list