commit 125664b: [Minor] Add safety checks when decoding CT attributes

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Apr 13 12:49:06 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-04-13 13:45:32 +0100
URL: https://github.com/rspamd/rspamd/commit/125664ba6cf0154c65691441a9fb3b9dc120336d (HEAD -> master)

[Minor] Add safety checks when decoding CT attributes

---
 src/libmime/content_type.c | 8 +++++---
 src/libmime/mime_headers.c | 4 ++++
 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));
 


More information about the Commits mailing list