changeset 931:d458f318ab02 HEAD

Make sure hdr->used_file_size isn't too small.
author Timo Sirainen <tss@iki.fi>
date Thu, 09 Jan 2003 14:35:16 +0200
parents fdcc1cab13ff
children ac69cabf9568
files src/lib-index/mail-index.c src/lib-index/mail-modifylog.c src/lib-index/mail-tree.c
diffstat 3 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Thu Jan 09 14:19:07 2003 +0200
+++ b/src/lib-index/mail-index.c	Thu Jan 09 14:35:16 2003 +0200
@@ -53,7 +53,8 @@
 		return FALSE;
 	}
 
-	if ((hdr->used_file_size - sizeof(struct mail_index_header)) %
+	if (hdr->used_file_size < sizeof(struct mail_index_header) ||
+	    (hdr->used_file_size - sizeof(struct mail_index_header)) %
 	    sizeof(struct mail_index_record) != 0) {
 		index_set_corrupted(index, "Invalid used_file_size in header "
 				    "(%"PRIuUOFF_T")",
--- a/src/lib-index/mail-modifylog.c	Thu Jan 09 14:19:07 2003 +0200
+++ b/src/lib-index/mail-modifylog.c	Thu Jan 09 14:35:16 2003 +0200
@@ -230,7 +230,8 @@
 		return FALSE;
 	}
 
-	if ((hdr->used_file_size - sizeof(struct modify_log_header)) %
+	if (hdr->used_file_size < sizeof(struct modify_log_header) ||
+	    (hdr->used_file_size - sizeof(struct modify_log_header)) %
 	    sizeof(struct modify_log_record) != 0) {
 		modifylog_set_corrupted(file,
 			"Invalid used_file_size in header (%"PRIuUOFF_T")",
--- a/src/lib-index/mail-tree.c	Thu Jan 09 14:19:07 2003 +0200
+++ b/src/lib-index/mail-tree.c	Thu Jan 09 14:35:16 2003 +0200
@@ -106,7 +106,8 @@
 		return FALSE;
 	}
 
-	if ((hdr->used_file_size - sizeof(struct mail_tree_header)) %
+	if (hdr->used_file_size < sizeof(struct mail_tree_header) ||
+	    (hdr->used_file_size - sizeof(struct mail_tree_header)) %
 	    sizeof(struct mail_tree_node) != 0) {
 		_mail_tree_set_corrupted(tree,
 			"Invalid used_file_size in header (%"PRIuUOFF_T")",