]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add safety checks when decoding CT attributes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Apr 2021 12:45:32 +0000 (13:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Apr 2021 12:45:32 +0000 (13:45 +0100)
src/libmime/content_type.c
src/libmime/mime_headers.c

index 4aa72cc7dd77dd816f3511f10a1104b36b788dfd..88102ad2c59581a23578073321576b2c3ea50ea0 100644 (file)
@@ -228,9 +228,11 @@ rspamd_postprocess_ct_attributes (rspamd_mempool_t *pool,
 
                gboolean invalid_utf = FALSE;
 
-               param->value.begin = rspamd_mime_header_decode (pool, param->value.begin,
-                               param->value.len, &invalid_utf);
-               param->value.len = strlen (param->value.begin);
+               if (param->value.begin != NULL && param->value.len > 0) {
+                       param->value.begin = rspamd_mime_header_decode(pool, param->value.begin,
+                                       param->value.len, &invalid_utf);
+                       param->value.len = strlen(param->value.begin);
+               }
 
                if (invalid_utf) {
                        param->flags |= RSPAMD_CONTENT_PARAM_BROKEN;
index 4d2c89dae5664273f365bab7313a7f5fae604b7e..9dc336cf756ee03affe117ec28b6b529356fc440 100644 (file)
@@ -1911,6 +1911,10 @@ rspamd_message_set_modified_header (struct rspamd_task *task,
 
                                        raw_value = ucl_object_tolstring (value, &raw_len);
 
+                                       if (raw_len == 0) {
+                                               continue;
+                                       }
+
                                        struct rspamd_mime_header *nhdr = rspamd_mempool_alloc0 (
                                                        task->task_pool, sizeof (*nhdr));