Skip to content

Commit

Permalink
[Fix] Include the last character when parsing the last header with no…
Browse files Browse the repository at this point in the history
… value

Issue: #4388
  • Loading branch information
vstakhov committed Apr 21, 2023
1 parent e60fa8d commit c19bd3b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/libmime/mime_headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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') {
Expand Down

0 comments on commit c19bd3b

Please sign in to comment.