]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: If message_part_data.content_type is set, make sure content_subtype isn...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 24 Jul 2018 11:55:25 +0000 (14:55 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 25 Jan 2019 09:16:33 +0000 (11:16 +0200)
This fixes a crash in index_mail_find_first_text_mime_part() where snippet
generation assumed that content_subtype isn't NULL.

src/lib-mail/message-part-data.c

index 35f35a0f9349f1889b93e222f43824ec199bc0cc..416dce6cc14bc5fc06abf33526864083f11dbbaf 100644 (file)
@@ -295,6 +295,12 @@ parse_content_type(struct message_part_data *data,
        }
        str_truncate(str, i);
        data->content_type = p_strdup(pool, str_c(str));
+       if (data->content_subtype == NULL) {
+               /* The Content-Type is invalid. Don't leave it NULL so that
+                  callers can assume that if content_type != NULL,
+                  content_subtype != NULL also. */
+               data->content_subtype = p_strdup(pool, "");
+       }
 
        if (ret < 0) {
                /* Content-Type is broken, but we wanted to get it as well as