aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/backends
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-28 14:34:14 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-28 14:34:14 +0100
commit1aa2cebd3eff78d1c9417a4267f81166147840ec (patch)
tree7ca6427cf2e74474119081a36deb1a1f71d8e61b /src/libstat/backends
parentd4bab2f70adbabf14e734f4c9bc497843c298f5c (diff)
downloadrspamd-1aa2cebd3eff78d1c9417a4267f81166147840ec.tar.gz
rspamd-1aa2cebd3eff78d1c9417a4267f81166147840ec.zip
[Minor] Another sanity check
Diffstat (limited to 'src/libstat/backends')
-rw-r--r--src/libstat/backends/mmaped_file.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c
index 86538039d..795da8b4d 100644
--- a/src/libstat/backends/mmaped_file.c
+++ b/src/libstat/backends/mmaped_file.c
@@ -494,14 +494,17 @@ rspamd_mmaped_file_reindex (rspamd_mempool_t *pool,
}
pos = map + (sizeof (struct stat_file) - sizeof (struct stat_file_block));
- while (old_size - (pos - map) >= sizeof (struct stat_file_block)) {
- block = (struct stat_file_block *)pos;
- if (block->hash1 != 0 && block->value != 0) {
- rspamd_mmaped_file_set_block_common (pool,
- new, block->hash1,
- block->hash2, block->value);
+
+ if (pos - map < (gssize)old_size) {
+ while ((gssize)old_size - (pos - map) >= (gssize)sizeof (struct stat_file_block)) {
+ block = (struct stat_file_block *)pos;
+ if (block->hash1 != 0 && block->value != 0) {
+ rspamd_mmaped_file_set_block_common (pool,
+ new, block->hash1,
+ block->hash2, block->value);
+ }
+ pos += sizeof (block);
}
- pos += sizeof (block);
}
header = (struct stat_file_header *)map;