]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Minor code cleanup
authorTimo Sirainen <tss@iki.fi>
Sat, 15 Feb 2014 01:41:29 +0000 (10:41 +0900)
committerTimo Sirainen <tss@iki.fi>
Sat, 15 Feb 2014 01:41:29 +0000 (10:41 +0900)
The previous calculation was correct also though.

src/lib-index/mail-cache-fields.c

index 91830250dbf545b1ff8269e463a4496104ab13a4..e45e3cddeeb6cd9294d5230c655d717ee1f6e426 100644 (file)
@@ -328,8 +328,7 @@ int mail_cache_header_fields_read(struct mail_cache *cache)
 
        /* check the fixed size of the header. name[] has to be checked
           separately */
-       if (field_hdr->size < sizeof(*field_hdr) +
-           field_hdr->fields_count * (sizeof(uint32_t)*2 + 1 + 2)) {
+       if (field_hdr->size < MAIL_CACHE_FIELD_NAMES(field_hdr->fields_count)) {
                mail_cache_set_corrupted(cache, "invalid field header size");
                return -1;
        }
@@ -356,6 +355,7 @@ int mail_cache_header_fields_read(struct mail_cache *cache)
        names = CONST_PTR_OFFSET(field_hdr,
                MAIL_CACHE_FIELD_NAMES(field_hdr->fields_count));
        end = CONST_PTR_OFFSET(field_hdr, field_hdr->size);
+       i_assert(names <= end);
 
        /* clear the old mapping */
        for (i = 0; i < cache->fields_count; i++)