From: David Levine Date: Fri, 21 Oct 2016 17:26:43 +0000 (-0400) Subject: Fixed MIME parser so it can read binary content. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/9374a77fec170451968e67eb90fce2c331b5040c?ds=sidebyside Fixed MIME parser so it can read binary content. Second of two-part fix. Replaced use of strlen(). --- diff --git a/Makefile.am b/Makefile.am index 54d87c16..fc1bceb8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -113,7 +113,6 @@ TESTS = test/ali/test-ali test/anno/test-anno \ test/cleanup ## The "cleanup" test should always be last. XFAIL_TESTS = \ - test/mhshow/test-binary \ test/scan/test-header-parsing \ # diff --git a/test/mhshow/test-binary b/test/mhshow/test-binary index e7407a82..95a30c70 100755 --- a/test/mhshow/test-binary +++ b/test/mhshow/test-binary @@ -27,7 +27,7 @@ Subject: test binary content MIME-Version: 1.0 -[ part - text/plain - 20B ] +[ part - text/plain - 23B ] Here's a null byte: " ". " diff --git a/uip/mhparse.c b/uip/mhparse.c index 5dae9fd7..c380969c 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -330,7 +330,15 @@ get_content (FILE *in, char *file, int toplevel) continue; case BODY: - ct->c_begin = ftell (in) - strlen (buf); + if (name[0] == ':') { + /* Special case: no blank line between header and body. The + file position indicator is on the newline at the end of the + line, but it needs to be one prior to the beginning of the + line. So subtract the length of the line, bufsz, plus 1. */ + ct->c_begin = ftell (in) - (bufsz + 1); + } else { + ct->c_begin = ftell (in) - (bufsz - 1); + } break; case FILEEOF: