aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/str_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-26 13:32:02 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-26 13:32:02 +0100
commit3fe38b276993ea34dd762ea95d5b56343081f3e7 (patch)
tree9f2b7f35f1b2d6f2c12f2fcdd1d74c8aa4a60339 /src/libutil/str_util.c
parent437d0e4fe7c2388753f01eab3c75ee01422ea9ea (diff)
downloadrspamd-3fe38b276993ea34dd762ea95d5b56343081f3e7.tar.gz
rspamd-3fe38b276993ea34dd762ea95d5b56343081f3e7.zip
[Fix] Fix folding algorithm to deal with empty tokens
Diffstat (limited to 'src/libutil/str_util.c')
-rw-r--r--src/libutil/str_util.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index 3ebf297fc..c12a9c562 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -1134,10 +1134,11 @@ rspamd_header_value_fold (const gchar *name,
break;
case fold_token:
/* Here, we have token start at 'c' and token end at 'p' */
- g_assert (p > c);
-
if (fold_type == fold_after) {
- g_string_append_len (res, c, p - c);
+
+ if (p > c) {
+ g_string_append_len (res, c, p - c);
+ }
switch (how) {
case RSPAMD_TASK_NEWLINES_LF:
@@ -1160,6 +1161,7 @@ rspamd_header_value_fold (const gchar *name,
cur_len = 0;
}
else {
+ g_assert (p > c);
/* Skip space if needed */
if (g_ascii_isspace (*c) && p > c) {
c ++;