diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-12-05 12:40:01 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-12-05 12:40:01 +0000 |
commit | 7d00ba404e3f7ae703503df765cfa04a6bc7d34f (patch) | |
tree | 246f92bbfc907b9e665a77d48053115c509dc419 /src/statfile.c | |
parent | c52921bf522b3dc7dfd72e9183b9ff8bba7a6c42 (diff) | |
download | rspamd-7d00ba404e3f7ae703503df765cfa04a6bc7d34f.tar.gz rspamd-7d00ba404e3f7ae703503df765cfa04a6bc7d34f.zip |
Fix resizing of statfiles.
Diffstat (limited to 'src/statfile.c')
-rw-r--r-- | src/statfile.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/statfile.c b/src/statfile.c index 9cc2d58f3..b4771ce15 100644 --- a/src/statfile.c +++ b/src/statfile.c @@ -235,7 +235,7 @@ statfile_pool_reindex (statfile_pool_t * pool, gchar *filename, size_t old_size, } pos = map + (sizeof (struct stat_file) - sizeof (struct stat_file_block)); - while (pos - map < (gint)old_size) { + while (old_size - (pos - map) >= sizeof (block)) { block = (struct stat_file_block *)pos; if (block->hash1 != 0 && block->value != 0) { statfile_pool_set_block_common (pool, new, block->hash1, block->hash2, 0, block->value, FALSE); @@ -307,7 +307,8 @@ statfile_pool_open (statfile_pool_t * pool, gchar *filename, size_t size, gboole } memory_pool_lock_mutex (pool->lock); - if (!forced && size != (size_t)st.st_size && size > sizeof (struct stat_file)) { + if (!forced && labs (size - st.st_size) > (long)sizeof (struct stat_file) * 2 + && size > sizeof (struct stat_file)) { memory_pool_unlock_mutex (pool->lock); msg_warn ("need to reindex statfile old size: %Hz, new size: %Hz", st.st_size, size); return statfile_pool_reindex (pool, filename, st.st_size, size); |