we've been having problems with nulls showing up in email. it turns out that the dot destuffing in smtpd is the culprit. i also added some extra paranoid stuff to the getnl() stuff to make the sender isn't messing with us. to trigger this bug send a mail with a dot on a line by itself. (or telnet to smtpd and forge the email yourself, this time doing the dot-stuffing by hand.) Reference: /n/sources/patch/applied/smtpdnull Date: Mon Oct 6 21:29:03 CES 2008 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/upas/smtp/smtpd.c Mon Oct 6 21:28:58 2008 +++ /sys/src/cmd/upas/smtp/smtpd.c Mon Oct 6 21:28:52 2008 @@ -718,6 +718,8 @@ fprint(2, "%c", c); } switch(c){ + case 0: + break; case -1: goto out; case '\r': @@ -1118,8 +1120,12 @@ sawdot = 1; break; } + if(cp[0] == '.'){ + cp++; + n--; + } nbytes += n; - if(status == 0 && Bwrite(pp->std[0]->fp, *cp == '.' ? cp+1 : cp, n) < 0){ + if(status == 0 && Bwrite(pp->std[0]->fp, cp, n) < 0){ piperror = "write error 3"; status = 1; }