From: Vsevolod Stakhov Date: Tue, 21 May 2019 18:51:23 +0000 (+0100) Subject: [CritFix] Fix case sensivity when parsing Content-Type X-Git-Tag: 1.9.4~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=83525c7c24a58526555e7b0dd4f008b61b468b0c;p=rspamd.git [CritFix] Fix case sensivity when parsing Content-Type --- diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c index b67ec155e..d092c0dc4 100644 --- a/src/libmime/content_type.c +++ b/src/libmime/content_type.c @@ -235,7 +235,7 @@ rspamd_content_type_postprocess (rspamd_mempool_t *pool, RSPAMD_FTOK_ASSIGN (&srch, "charset"); - if (rspamd_ftok_cmp (¶m->name, &srch) == 0) { + if (rspamd_ftok_casecmp (¶m->name, &srch) == 0) { /* Adjust charset */ found = param; ct->charset.begin = param->value.begin; @@ -244,7 +244,7 @@ rspamd_content_type_postprocess (rspamd_mempool_t *pool, RSPAMD_FTOK_ASSIGN (&srch, "boundary"); - if (rspamd_ftok_cmp (¶m->name, &srch) == 0) { + if (rspamd_ftok_casecmp (¶m->name, &srch) == 0) { found = param; gchar *lc_boundary; /* Adjust boundary */ @@ -275,7 +275,7 @@ rspamd_content_disposition_postprocess (rspamd_mempool_t *pool, srch.begin = "filename"; srch.len = 8; - if (rspamd_ftok_cmp (¶m->name, &srch) == 0) { + if (rspamd_ftok_casecmp (¶m->name, &srch) == 0) { /* Adjust filename */ cd->filename.begin = param->value.begin; cd->filename.len = param->value.len; @@ -610,12 +610,12 @@ rspamd_content_type_parse (const gchar *in, { struct rspamd_content_type *res = NULL; rspamd_ftok_t srch; - gchar *lc_data; + gchar *cpy; - lc_data = rspamd_mempool_alloc (pool, len + 1); - rspamd_strlcpy (lc_data, in, len + 1); + cpy = rspamd_mempool_alloc (pool, len + 1); + rspamd_strlcpy (cpy, in, len + 1); - if ((res = rspamd_content_type_parser (lc_data, len, pool)) != NULL) { + if ((res = rspamd_content_type_parser (cpy, len, pool)) != NULL) { if (res->attrs) { rspamd_mempool_add_destructor (pool, (rspamd_mempool_destruct_t)g_hash_table_unref, res->attrs); @@ -629,7 +629,7 @@ rspamd_content_type_parse (const gchar *in, res->flags |= RSPAMD_CONTENT_TYPE_BROKEN; RSPAMD_FTOK_ASSIGN (&srch, "text"); - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->type, &srch) == 0) { /* Workaround for Content-Type: text */ /* Assume text/plain */ RSPAMD_FTOK_ASSIGN (&srch, "plain"); @@ -637,7 +637,7 @@ rspamd_content_type_parse (const gchar *in, else { RSPAMD_FTOK_ASSIGN (&srch, "html"); - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->type, &srch) == 0) { /* Workaround for Content-Type: html */ RSPAMD_FTOK_ASSIGN (&res->type, "text"); RSPAMD_FTOK_ASSIGN (&res->subtype, "html"); @@ -645,7 +645,7 @@ rspamd_content_type_parse (const gchar *in, else { RSPAMD_FTOK_ASSIGN (&srch, "application"); - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->type, &srch) == 0) { RSPAMD_FTOK_ASSIGN (&res->subtype, "octet-stream"); } } @@ -655,7 +655,7 @@ rspamd_content_type_parse (const gchar *in, /* Common mistake done by retards */ RSPAMD_FTOK_ASSIGN (&srch, "alternate"); - if (rspamd_ftok_cmp (&res->subtype, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->subtype, &srch) == 0) { res->flags |= RSPAMD_CONTENT_TYPE_BROKEN; RSPAMD_FTOK_ASSIGN (&res->subtype, "alternative"); } @@ -663,22 +663,22 @@ rspamd_content_type_parse (const gchar *in, RSPAMD_FTOK_ASSIGN (&srch, "multipart"); - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->type, &srch) == 0) { res->flags |= RSPAMD_CONTENT_TYPE_MULTIPART; } else { RSPAMD_FTOK_ASSIGN (&srch, "text"); - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->type, &srch) == 0) { res->flags |= RSPAMD_CONTENT_TYPE_TEXT; } else { RSPAMD_FTOK_ASSIGN (&srch, "message"); - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->type, &srch) == 0) { RSPAMD_FTOK_ASSIGN (&srch, "delivery-status"); - if (rspamd_ftok_cmp (&res->subtype, &srch) == 0) { + if (rspamd_ftok_casecmp (&res->subtype, &srch) == 0) { res->flags |= RSPAMD_CONTENT_TYPE_TEXT|RSPAMD_CONTENT_TYPE_DSN; } else { @@ -698,7 +698,7 @@ rspamd_content_type_parse (const gchar *in, } } else { - msg_warn_pool ("cannot parse content type: %*s", (gint)len, lc_data); + msg_warn_pool ("cannot parse content type: %*s", (gint)len, cpy); } return res;