From: Ken Hornstein Date: Mon, 29 Apr 2019 01:07:24 +0000 (-0400) Subject: Permit the matching of canonical MIME multipart boundaries X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/56a43385fdcbbe0de9cc6bd74b708d66e3c63cbf Permit the matching of canonical MIME multipart boundaries Allow the matching of MIME multipart boundaries if the message is in canonical form (\r\n line endings). --- diff --git a/uip/mhparse.c b/uip/mhparse.c index f0cdc687..fe185309 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -1153,6 +1153,23 @@ InitMultiPart (CT ct) pos += gotlen; if (bufp[0] != '-' || bufp[1] != '-') continue; + + /* + * A bit of a lame hack; if this line ends in \r\n then replace + * the \r\n with just a \n so that the boundary markers will match + * up properly in case this uses "MS-DOS" line endings. + */ + + if (gotlen > 2 && bufp[gotlen - 1] == '\n' && + bufp[gotlen - 2] == '\r') { + /* + * Note we don't change getpos here, because it is used to + * calculate multipart offsets. + */ + bufp[gotlen - 2] = '\n'; + bufp[gotlen - 1] = '\0'; + } + if (inout) { if (strcmp (bufp + 2, m->mp_start)) continue;