]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: If cache file unexpectedly shrinks in header lookup, log an error.
authorTimo Sirainen <tss@iki.fi>
Fri, 26 Oct 2012 08:34:25 +0000 (11:34 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 26 Oct 2012 08:34:25 +0000 (11:34 +0300)
src/lib-index/mail-cache-lookup.c

index 0dea4e215455382de6ba84b948b4dd77a2151ac3..1a9f2b1c8ec1619cbf88f0c4091a2cdd47ecd5b5 100644 (file)
@@ -538,9 +538,16 @@ mail_cache_lookup_headers_real(struct mail_cache_view *view, string_t *dest,
 
        /* then start filling dest buffer from the headers */
        for (i = 0; i < count; i++) {
-               if (mail_cache_map(cache, lines[i].data->offset,
-                                  lines[i].data->data_size, &data) <= 0)
+               ret = mail_cache_map(cache, lines[i].data->offset,
+                                    lines[i].data->data_size, &data);
+               if (ret <= 0) {
+                       if (ret < 0)
+                               return -1;
+
+                       mail_cache_set_corrupted(cache,
+                               "header record unexpectedly points outside file");
                        return -1;
+               }
                start = data;
                end = start + lines[i].data->data_size;