[dovecot-cvs] dovecot/src/lib-index mail-index.c,1.187,1.188

cras at dovecot.org cras at dovecot.org
Wed Feb 9 00:44:49 EET 2005


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv4237/lib-index

Modified Files:
	mail-index.c 
Log Message:
Don't allow duplicate extension names in index header.



Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- mail-index.c	31 Jan 2005 18:03:43 -0000	1.187
+++ mail-index.c	8 Feb 2005 22:44:47 -0000	1.188
@@ -185,6 +185,7 @@
 	} else {
 		idx = map->extensions->used / sizeof(*ext);
 	}
+	i_assert(mail_index_map_lookup_ext(map, name) == (uint32_t)-1);
 
 	ext = buffer_append_space_unsafe(map->extensions, sizeof(*ext));
 	memset(ext, 0, sizeof(*ext));
@@ -259,6 +260,7 @@
 				index->filepath);
 			return -1;
 		}
+
 		offset += sizeof(*ext_hdr);
 		name_offset = offset;
 		offset += ext_hdr->name_size + get_align(ext_hdr->name_size);
@@ -266,6 +268,15 @@
 		t_push();
 		name = t_strndup(CONST_PTR_OFFSET(map->hdr_base, name_offset),
 				 ext_hdr->name_size);
+
+		if (mail_index_map_lookup_ext(map, name) != (uint32_t)-1) {
+			mail_index_set_error(index, "Corrupted index file %s: "
+				"Duplicate header extension %s",
+				index->filepath, name);
+			t_pop();
+			return -1;
+		}
+
 		mail_index_map_register_ext(index, map, name,
 					    offset, ext_hdr->hdr_size,
 					    ext_hdr->record_offset,



More information about the dovecot-cvs mailing list