aboutsummaryrefslogtreecommitdiffstats
path: root/src/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-10-17 21:04:29 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-10-17 21:04:29 +0300
commitbb783aa50c87907a2012d6979b47e10c9189892e (patch)
tree1f02a3072cc00f23047b07dc6728aa7d6e02c10b /src/cfg_utils.c
parentdf46d970cdea50a41ae54d9125d61458c59486d7 (diff)
downloadrspamd-bb783aa50c87907a2012d6979b47e10c9189892e.tar.gz
rspamd-bb783aa50c87907a2012d6979b47e10c9189892e.zip
* Add configuration utils for kvstorage
Diffstat (limited to 'src/cfg_utils.c')
-rw-r--r--src/cfg_utils.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c
index 203133e77..ffebd5c46 100644
--- a/src/cfg_utils.c
+++ b/src/cfg_utils.c
@@ -268,16 +268,17 @@ get_module_opt (struct config_file *cfg, gchar *module_name, gchar *opt_name)
}
gsize
-parse_limit (const gchar *limit)
+parse_limit (const gchar *limit, guint len)
{
gsize result = 0;
- gchar *err_str;
+ const gchar *err_str;
- if (!limit || *limit == '\0')
+ if (!limit || *limit == '\0' || len == 0) {
return 0;
+ }
errno = 0;
- result = strtoul (limit, &err_str, 10);
+ result = strtoul (limit, (gchar **)&err_str, 10);
if (*err_str != '\0') {
/* Megabytes */
@@ -292,7 +293,7 @@ parse_limit (const gchar *limit)
else if (*err_str == 'g' || *err_str == 'G') {
result *= 1073741824L;
}
- else {
+ else if (len > 0 && err_str - limit != len) {
msg_warn ("invalid limit value '%s' at position '%s'", limit, err_str);
result = 0;
}