aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-04-13 13:45:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-04-13 13:45:32 +0100
commit125664ba6cf0154c65691441a9fb3b9dc120336d (patch)
tree9d9c7fccf6c0908b875cef222f8af1ad59d2ffe7 /src/libmime
parentec5db547fe2bdbbe4d89661eee082ee3e509f63e (diff)
downloadrspamd-125664ba6cf0154c65691441a9fb3b9dc120336d.tar.gz
rspamd-125664ba6cf0154c65691441a9fb3b9dc120336d.zip
[Minor] Add safety checks when decoding CT attributes
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/content_type.c8
-rw-r--r--src/libmime/mime_headers.c4
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c
index 4aa72cc7d..88102ad2c 100644
--- a/src/libmime/content_type.c
+++ b/src/libmime/content_type.c
@@ -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;
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 4d2c89dae..9dc336cf7 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -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));