aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-03 13:38:34 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-03 13:40:24 +0100
commitce2bc972d0806e3254412afc4a0df2d89931f9d1 (patch)
tree6d929f31afdb33e4e3a287cb0dd79d8cd0838997 /src/libutil
parente4aa032337d90a2f866409377b0b6cd61c677fbe (diff)
downloadrspamd-ce2bc972d0806e3254412afc4a0df2d89931f9d1.tar.gz
rspamd-ce2bc972d0806e3254412afc4a0df2d89931f9d1.zip
Fix reading of maps with comments.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/map.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 13b6483ab..84c9f1b29 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -751,7 +751,7 @@ abstract_parse_kv_list (rspamd_mempool_t * pool,
break;
case 100:
/* Skip \r\n and whitespaces */
- if (*p == '\r' || *p == '\n' || g_ascii_isspace (*p)) {
+ if (*p == '\r' || *p == '\n' || *p == '\0' || g_ascii_isspace (*p)) {
p++;
}
else {
@@ -791,9 +791,10 @@ rspamd_parse_abstract_list (rspamd_mempool_t * pool,
if (s) {
func (data->cur_data, s, hash_fill);
+ msg_debug_pool ("insert element (before comment): %s", s);
}
- c = p;
}
+ c = NULL;
data->state = 1;
}
else if (*p == '\r' || *p == '\n' || p == end) {
@@ -802,14 +803,20 @@ rspamd_parse_abstract_list (rspamd_mempool_t * pool,
if (s) {
func (data->cur_data, s, hash_fill);
+ msg_debug_pool ("insert element (before EOL): %s", s);
}
/* Skip EOL symbols */
- while ((*p == '\r' || *p == '\n') && p <= end) {
+ while ((*p == '\r' || *p == '\n') && p < end) {
p++;
}
- c = p;
- p ++;
+ if (p == end) {
+ p ++;
+ c = NULL;
+ }
+ else {
+ c = p;
+ }
}
else {
p++;
@@ -819,11 +826,17 @@ rspamd_parse_abstract_list (rspamd_mempool_t * pool,
case 1:
/* Skip comment till end of line */
if (*p == '\r' || *p == '\n') {
- while ((*p == '\r' || *p == '\n') && p <= end) {
+ while ((*p == '\r' || *p == '\n') && p < end) {
p++;
}
- c = p;
- p ++;
+
+ if (p == end) {
+ p ++;
+ c = NULL;
+ }
+ else {
+ c = p;
+ }
data->state = 0;
}
else {
@@ -833,6 +846,10 @@ rspamd_parse_abstract_list (rspamd_mempool_t * pool,
}
}
+ if (c >= end) {
+ c = NULL;
+ }
+
return c;
}