From: Vsevolod Stakhov Date: Mon, 26 Sep 2016 12:32:02 +0000 (+0100) Subject: [Fix] Fix folding algorithm to deal with empty tokens X-Git-Tag: 1.4.0~373 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3fe38b276993ea34dd762ea95d5b56343081f3e7;p=rspamd.git [Fix] Fix folding algorithm to deal with empty tokens --- 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 ++;