I wrote: > This might not be much of a lift. m_getfld might handle NULs in bodies, > and the MIME parser comes close to handling them as well.
m_getfld and the MIME parser do handle NULs. post(8) doesn't. I'd like to commit the attached patch. It uses write(2) instead of fprintf(3) and fputs(3). All tests pass with it. Any objection? While SMTP servers still might not be able to handle NULs, I don't think that nmh should block them. > mhshow has a test-binary that says that it reads a null byte, but it's > just a space. That was incorrect. printf(1) wrote out the NUL. I'll add a comment to the test to make that clearer. David
diff --git a/uip/post.c b/uip/post.c index 820ed05b..010bcf1e 100644 --- a/uip/post.c +++ b/uip/post.c @@ -340 +340 @@ main (int argc, char **argv) - int state, compnum, dashstuff = 0, swnum; + int state, compnum, dashstuff = 0, swnum, out_fd; @@ -632 +632 @@ main (int argc, char **argv) - char *cp = m_mktemp2(NULL, invo_name, NULL, &out); + char *cp = m_mktemp2(NULL, invo_name, &out_fd, &out); @@ -664 +664,5 @@ main (int argc, char **argv) - fprintf (out, "\n%s", buf); + write (out_fd, "\n", 1); + /* Don't emit trailing NUL to avoid interfering with SMTP + conversation. */ + write (out_fd, buf, + bufsz >= 1 && buf[bufsz-1] == '\0' ? bufsz-1 : bufsz); @@ -668 +672 @@ main (int argc, char **argv) - fputs (buf, out); + write (out_fd, buf, bufsz); @@ -1240,0 +1245 @@ finish_headers (FILE *out) + fflush (out);
