It seems there's some improvements to be done in the interaction between e.g. mime_scanner_get() and mime_parser_parse(). For example:
1) mime_scanner_get() does not recognize the ':' as it's walking the string looking for cr/lf's, WS's for continuations etc. Seems like it'd make sense here to also mark the position of the ':', such that the caller doesn't have to look for that again (mime_parser_parse() will call memchr() to find it).
2) mime_scanner_get() doesn't deal with various illegal characters, either leaving it up to the caller(s) to deal with, or not being dealt with at all. It seems it'd be pretty easy to include the checks for that here, and then avoid any checks further up in the calling chain entirely.
3) mime_scanner_parse() does not properly deal with white spaces before the ':', which is a protocol error (instead we just ignore 'em).
It's possible 3) should be its own Jira, but seems easy to do all this as one fix honestly.