]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
cache file: If offset isn't 32bit aligned, assume it's corrupted.
authorTimo Sirainen <tss@iki.fi>
Mon, 27 Jul 2009 02:40:02 +0000 (22:40 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 27 Jul 2009 02:40:02 +0000 (22:40 -0400)
--HG--
branch : HEAD

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

index 21aaf5c96a261e81aaf655c72f834e2dff83f0d5..6a661f418bedcde3a785e9b7490523e05b7f11e6 100644 (file)
@@ -17,6 +17,12 @@ int mail_cache_get_record(struct mail_cache *cache, uint32_t offset,
 
        i_assert(offset != 0);
 
+       if (offset % sizeof(uint32_t) != 0) {
+               /* records are always 32-bit aligned */
+               mail_cache_set_corrupted(cache, "invalid record offset");
+               return -1;
+       }
+
        /* we don't know yet how large the record is, so just guess */
        if (mail_cache_map(cache, offset, sizeof(*rec) + CACHE_PREFETCH) < 0)
                return -1;