diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-04-21 21:11:11 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-04-21 21:12:00 +0100 |
commit | c19bd3bfb4b73cd84481ab855a60d2f2471570dd (patch) | |
tree | b3ddaf78629a9b793eb8c728fbdde4d41f2b3a44 | |
parent | e60fa8d9e02e91987633a2af5b1479bf3966569f (diff) | |
download | rspamd-c19bd3bfb4b73cd84481ab855a60d2f2471570dd.tar.gz rspamd-c19bd3bfb4b73cd84481ab855a60d2f2471570dd.zip |
[Fix] Include the last character when parsing the last header with no value
Issue: #4388
-rw-r--r-- | src/libmime/mime_headers.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index e75a61366..422c9b8f8 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -194,7 +194,7 @@ rspamd_mime_headers_process (struct rspamd_task *task, const gchar *p, *c, *end; gchar *tmp, *tp; gint state = 0, l, next_state = 100, err_state = 100, t_state; - gboolean valid_folding = FALSE; + gboolean valid_folding = FALSE, shift_by_one = FALSE; guint nlines_count[RSPAMD_TASK_NEWLINES_MAX]; guint norder = 0; @@ -410,9 +410,12 @@ rspamd_mime_headers_process (struct rspamd_task *task, break; case 5: /* Header has only name, no value */ - nh->value = rspamd_mempool_strdup (task->task_pool, "");; - nh->decoded = rspamd_mempool_strdup (task->task_pool, "");; + nh->value = rspamd_mempool_strdup (task->task_pool, ""); + nh->decoded = rspamd_mempool_strdup (task->task_pool, ""); nh->raw_len = p - nh->raw_value; + if (shift_by_one) { + nh->raw_len ++; + } nh->order = norder ++; rspamd_mime_header_add (task, &target->htb, order_ptr, nh, check_newlines); nh = NULL; @@ -422,6 +425,8 @@ rspamd_mime_headers_process (struct rspamd_task *task, /* Folding state */ if (p + 1 == end) { state = err_state; + /* Include the last character into the next header */ + shift_by_one = TRUE; } else { if (*p == '\r' || *p == '\n') { |