diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libmime/archives.c | 6 | ||||
-rw-r--r-- | src/libmime/mime_encoding.c | 8 | ||||
-rw-r--r-- | src/libmime/mime_parser.c | 12 |
3 files changed, 16 insertions, 10 deletions
diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 1101213d1..467f9c021 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -141,7 +141,7 @@ rspamd_archive_process_zip (struct rspamd_task *task, guint32 cd_offset, cd_size, comp_size, uncomp_size, processed = 0; guint16 extra_len, fname_len, comment_len; struct rspamd_archive *arch; - struct rspamd_archive_file *f; + struct rspamd_archive_file *f = NULL; /* Zip files have interesting data at the end of archive */ p = part->parsed_data.begin + part->parsed_data.len - 1; @@ -1263,6 +1263,7 @@ rspamd_7zip_read_substreams_info (struct rspamd_task *task, } folder_nstreams = g_alloca (sizeof (guint64) * num_folders); + memset (folder_nstreams, 0, sizeof (guint64) * num_folders); while (p != NULL && p < end) { /* @@ -1410,9 +1411,10 @@ rspamd_7zip_read_archive_props (struct rspamd_task *task, */ proptype = *p; - SZ_SKIP_BYTES(1); if (p != NULL) { + SZ_SKIP_BYTES(1); + while (proptype != 0) { SZ_READ_VINT(proplen); diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index edbee1a30..a3467fc91 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -638,14 +638,14 @@ rspamd_mime_charset_find_by_content_maybe_split (const gchar *in, gsize inlen) RSPAMD_CHARSET_MAX_CONTENT, false); /* 7bit stuff */ - if (strcmp (c1, "US-ASCII") == 0) { + if (c1 && strcmp (c1, "US-ASCII") == 0) { c1 = NULL; /* Invalid - we have 8 bit there */ } - if (strcmp (c2, "US-ASCII") == 0) { + if (c2 && strcmp (c2, "US-ASCII") == 0) { c2 = NULL; /* Invalid - we have 8 bit there */ } - if (strcmp (c3, "US-ASCII") == 0) { - c2 = NULL; /* Invalid - we have 8 bit there */ + if (c3 && strcmp (c3, "US-ASCII") == 0) { + c3 = NULL; /* Invalid - we have 8 bit there */ } if (!c1) { diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c index 0363d4514..6ec28e057 100644 --- a/src/libmime/mime_parser.c +++ b/src/libmime/mime_parser.c @@ -596,14 +596,14 @@ rspamd_mime_parse_normal_part (struct rspamd_task *task, g_assert (part != NULL); rspamd_mime_part_get_cte (task, part->raw_headers, part, - !(part->ct->flags & RSPAMD_CONTENT_TYPE_MESSAGE)); + part->ct && !(part->ct->flags & RSPAMD_CONTENT_TYPE_MESSAGE)); rspamd_mime_part_get_cd (task, part); switch (part->cte) { case RSPAMD_CTE_7BIT: case RSPAMD_CTE_8BIT: case RSPAMD_CTE_UNKNOWN: - if (part->ct->flags & RSPAMD_CONTENT_TYPE_MISSING) { + if (part->ct && (part->ct->flags & RSPAMD_CONTENT_TYPE_MISSING)) { if (part->cte != RSPAMD_CTE_7BIT) { /* We have something that has a missing content-type, * but it has non-7bit characters. @@ -658,7 +658,9 @@ rspamd_mime_parse_normal_part (struct rspamd_task *task, } else { msg_err_task ("invalid quoted-printable encoded part, assume 8bit"); - part->ct->flags |= RSPAMD_CONTENT_TYPE_BROKEN; + if (part->ct) { + part->ct->flags |= RSPAMD_CONTENT_TYPE_BROKEN; + } part->cte = RSPAMD_CTE_8BIT; memcpy (parsed->str, part->raw_data.begin, part->raw_data.len); parsed->len = part->raw_data.len; @@ -694,7 +696,9 @@ rspamd_mime_parse_normal_part (struct rspamd_task *task, } else { msg_err_task ("invalid uuencoding in encoded part, assume 8bit"); - part->ct->flags |= RSPAMD_CONTENT_TYPE_BROKEN; + if (part->ct) { + part->ct->flags |= RSPAMD_CONTENT_TYPE_BROKEN; + } part->cte = RSPAMD_CTE_8BIT; parsed->len = MIN (part->raw_data.len, parsed->allocated); memcpy (parsed->str, part->raw_data.begin, parsed->len); |