diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-07-22 13:08:43 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-07-22 13:08:43 +0300 |
commit | 5b3431af0bfd1f51224a9c2b0709184a0cc944a7 (patch) | |
tree | d795fc20ad8a30b7e75bded188724ed0bcbf4591 /lib | |
parent | 2d9c9918fce547f88236598804fe5c4286f8cf53 (diff) | |
download | mailutils-5b3431af0bfd1f51224a9c2b0709184a0cc944a7.tar.gz mailutils-5b3431af0bfd1f51224a9c2b0709184a0cc944a7.tar.bz2 |
Stricter parsing of structured MIME headers
The mu_content_type_parse function allowed for missing
/subtype, which caused grief in case of blatantly invalid
inputs.
* decodemail/decodemail.c (message_decode): Handle
mu_content_type_parse failures racefully: return a reference to
the input message.
Improve diagnostics.
* lib/mdecode.c (message_body_stream): Improve diagnostics.
* libmailutils/base/assoc.c (merge_sort): Bugfix: accept empty
input list.
* libmailutils/base/ctparse.c (content_type_parse): Require that
both type and subtype be present.
* libmailutils/mime/mimehdr.c (_mime_header_parse): Move parameter
parsing to a separate function. Do better syntax checking.
* libmailutils/tests/Makefile.am: Add new tests.
* libmailutils/tests/testsuite.at: Likewise.
* libmailutils/tests/content-type.at: New tests.
* libmailutils/tests/conttype.c: Return 1 if at least one parse
fails.
* libmailutils/tests/mimehdr.at: Add tests for invalid inputs.
* libmailutils/tests/mimehdr.c: Better diagnostics.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mdecode.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/mdecode.c b/lib/mdecode.c index 0821a717b..355bb45b7 100644 --- a/lib/mdecode.c +++ b/lib/mdecode.c @@ -212,13 +212,14 @@ message_body_stream (mu_message_t msg, int unix_header, char const *charset, } rc = mu_content_type_parse (buf, NULL, &ct); - free (buf); - buf = NULL; if (rc) { - mu_diag_funcall (MU_DIAG_ERROR, "mu_content_type_parse", NULL, rc); + mu_diag_funcall (MU_DIAG_ERROR, "mu_content_type_parse", buf, rc); + free (buf); return rc; } + free (buf); + buf = NULL; if (is_text_part (ct)) /* Process only textual parts */ |