From 86e730e54fbb3348b60bf8d8279ba1100e46f66c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 5 Dec 2013 00:09:33 +0000 Subject: [PATCH] Do not actually allow to set zero size to statfiles. --- src/statfile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/statfile.c b/src/statfile.c index 9930e0fe0..b5d467426 100644 --- a/src/statfile.c +++ b/src/statfile.c @@ -307,11 +307,14 @@ statfile_pool_open (statfile_pool_t * pool, gchar *filename, size_t size, gboole } memory_pool_lock_mutex (pool->lock); - if (!forced && abs (st.st_size - size) > (gint)sizeof (struct stat_file)) { + if (!forced && 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); } + else if (size < sizeof (struct stat_file)) { + msg_err ("requested to shrink statfile to %Hz but it is too small", size); + } new_file = &pool->files[pool->opened++]; bzero (new_file, sizeof (stat_file_t)); -- 2.39.5