dovecot-1.0: Don't crash if extension record size is 0.

dovecot at dovecot.org dovecot at dovecot.org
Tue Jul 10 20:20:57 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/5f6e24834919
changeset: 5338:5f6e24834919
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 08 19:45:58 2007 +0300
description:
Don't crash if extension record size is 0.

diffstat:

2 files changed, 5 insertions(+), 3 deletions(-)
src/lib-index/mail-index-sync-ext.c |    3 ++-
src/lib-index/mail-index.c          |    5 +++--

diffs (28 lines):

diff -r f0bf2439bc09 -r 5f6e24834919 src/lib-index/mail-index-sync-ext.c
--- a/src/lib-index/mail-index-sync-ext.c	Thu Jul 05 18:16:26 2007 +0300
+++ b/src/lib-index/mail-index-sync-ext.c	Sun Jul 08 19:45:58 2007 +0300
@@ -191,7 +191,8 @@ sync_ext_reorder(struct mail_index_map *
 			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)
diff -r f0bf2439bc09 -r 5f6e24834919 src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c	Thu Jul 05 18:16:26 2007 +0300
+++ b/src/lib-index/mail-index.c	Sun Jul 08 19:45:58 2007 +0300
@@ -350,8 +350,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);


More information about the dovecot-cvs mailing list