]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix folding algorithm to deal with empty tokens
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 26 Sep 2016 12:32:02 +0000 (13:32 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 26 Sep 2016 12:32:02 +0000 (13:32 +0100)
src/libutil/str_util.c

index 3ebf297fc5b2ed2f20d348098048ae563074bd21..c12a9c56219eca4e17b93ece754871efa2679234 100644 (file)
@@ -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 ++;