]> source.dussan.org Git - rspamd.git/commitdiff
[CritFix] Fix semicolons parsing in the content type
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 13 Jul 2017 18:33:42 +0000 (19:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 13 Jul 2017 18:33:42 +0000 (19:33 +0100)
src/libmime/content_type.c
src/libmime/mime_parser.c

index 9e132253ad0282025db3320ad30d05a2cfe0726e..240e2fab503d518644959973f3c4d747c07d60fa 100644 (file)
@@ -218,7 +218,20 @@ rspamd_content_type_parser (const gchar *in, gsize len, rspamd_mempool_t *pool)
                                next_state = parse_param_name;
                                pname_start = NULL;
                                pname_end = NULL;
-                       } else {
+                       }
+                       else if (*p == ';') {
+                               if (pname_start && pname_end && pname_end > pname_start) {
+                                       rspamd_content_type_add_param (pool, &val, pname_start,
+                                                       pname_end, c, p);
+                               }
+
+                               p ++;
+                               state = parse_space;
+                               next_state = parse_param_name;
+                               pname_start = NULL;
+                               pname_end = NULL;
+                       }
+                       else {
                                p++;
                        }
                        break;
@@ -311,6 +324,10 @@ rspamd_content_type_parser (const gchar *in, gsize len, rspamd_mempool_t *pool)
                break;
        case parse_param_value:
                if (pname_start && pname_end && pname_end > pname_start) {
+                       if (p > c && *(p - 1) == ';') {
+                               p --;
+                       }
+
                        rspamd_content_type_add_param (pool, &val, pname_start,
                                        pname_end, c, p);
 
index ab83c09ace83444acc9f3fbd04178779d48c5684..d0862e7b453431ec453d8fe7840f82f9b564b9e7 100644 (file)
@@ -53,6 +53,7 @@ struct rspamd_mime_parser_ctx {
        const gchar *start;
        const gchar *pos;
        const gchar *end;
+       struct rspamd_task *task;
 };
 
 static gboolean
@@ -688,7 +689,8 @@ rspamd_multipart_boundaries_filter (struct rspamd_task *task,
                if (cur->start >= multipart->raw_data.begin - st->start) {
                        if (cb->cur_boundary) {
                                /* Check boundary */
-                               msg_debug_mime ("compare %L and %L", cb->bhash, cur->hash);
+                               msg_debug_mime ("compare %L and %L (and %L)",
+                                               cb->bhash, cur->hash, cur->closed_hash);
 
                                if (cb->bhash == cur->hash) {
                                        sel = i;
@@ -834,6 +836,9 @@ rspamd_mime_preprocess_cb (struct rspamd_multipattern *mp,
        gboolean closing = FALSE;
        struct rspamd_mime_boundary b;
        struct rspamd_mime_parser_ctx *st = context;
+       struct rspamd_task *task;
+
+       task = st->task;
 
        if (G_LIKELY (p < end)) {
                blen = rspamd_memcspn (p, "\r\n", end - p);
@@ -887,12 +892,14 @@ rspamd_mime_preprocess_cb (struct rspamd_multipattern *mp,
 
                        rspamd_cryptobox_siphash ((guchar *)&b.hash, lc_copy, blen,
                                        lib_ctx->hkey);
+                       msg_debug_mime ("normal hash: %*s -> %L", blen, lc_copy);
 
                        if (closing) {
                                b.flags = RSPAMD_MIME_BOUNDARY_FLAG_CLOSED;
                                rspamd_cryptobox_siphash ((guchar *)&b.closed_hash, lc_copy,
                                                blen + 2,
                                                lib_ctx->hkey);
+                               msg_debug_mime ("closing hash: %*s -> %L", blen + 2, lc_copy);
                        }
                        else {
                                b.flags = 0;
@@ -1137,6 +1144,7 @@ rspamd_mime_parse_message (struct rspamd_task *task,
                nst->start = part->parsed_data.begin;
                nst->end = nst->start + part->parsed_data.len;
                nst->pos = nst->start;
+               nst->task = st->task;
 
                str.str = (gchar *)part->parsed_data.begin;
                str.len = part->parsed_data.len;
@@ -1256,6 +1264,7 @@ rspamd_mime_parse_task (struct rspamd_task *task, GError **err)
        st->end = task->msg.begin + task->msg.len;
        st->boundaries = g_array_sized_new (FALSE, FALSE,
                        sizeof (struct rspamd_mime_boundary), 8);
+       st->task = task;
 
        if (st->pos == NULL) {
                st->pos = task->msg.begin;