]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: mail_cache_map() - Fix handling huge size values correctly
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 8 Aug 2020 09:11:54 +0000 (12:11 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 18 Mar 2021 14:05:44 +0000 (14:05 +0000)
offset+size could have wrapped in 32bit systems.

src/lib-index/mail-cache.c

index 9cb4ae60b814c6ac9b3e1ba4a8111b50d5e757df..07e6238f12a26935426ec6172c55ff80f737c160 100644 (file)
@@ -426,7 +426,7 @@ mail_cache_map_full(struct mail_cache *cache, size_t offset, size_t size,
                        *data_r = NULL;
                        return 0;
                }
-               if (offset + size > (uoff_t)st.st_size)
+               if (size > (uoff_t)st.st_size - offset)
                        size = st.st_size - offset;
        }