diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-15 15:07:24 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-15 15:07:24 +0000 |
commit | 4cd82b05a91ce79c3c84845189311c844ff587b4 (patch) | |
tree | 38a17d60f7da1de6ebb935e4e4efe0bab73e655f | |
parent | 418b59eb3b01a3729146e3d48c96a5687baed2c9 (diff) | |
download | rspamd-4cd82b05a91ce79c3c84845189311c844ff587b4.tar.gz rspamd-4cd82b05a91ce79c3c84845189311c844ff587b4.zip |
Do not create too small statfiles.
-rw-r--r-- | src/statfile.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/statfile.c b/src/statfile.c index 560a06def..c2ca57213 100644 --- a/src/statfile.c +++ b/src/statfile.c @@ -229,6 +229,12 @@ statfile_pool_reindex (statfile_pool_t * pool, gchar *filename, size_t old_size, struct stat_file_block *block; struct stat_file_header *header; + if (size < + sizeof (struct stat_file_header) + sizeof (struct stat_file_section) + sizeof (block)) { + msg_err ("file %s is too small to carry any statistic: %z", filename, size); + return NULL; + } + /* First of all rename old file */ memory_pool_lock_mutex (pool->lock); @@ -464,6 +470,12 @@ statfile_pool_create (statfile_pool_t * pool, gchar *filename, size_t size) return 0; } + if (size < + sizeof (struct stat_file_header) + sizeof (struct stat_file_section) + sizeof (block)) { + msg_err ("file %s is too small to carry any statistic: %z", filename, size); + return -1; + } + memory_pool_lock_mutex (pool->lock); nblocks = (size - sizeof (struct stat_file_header) - sizeof (struct stat_file_section)) / sizeof (struct stat_file_block); header.total_blocks = nblocks; |