When mail comes in for local delivery with two consecutive lines
beginning 'From ' only the first is escaped with a >. Two non-
consecutive 'From ' lines in one message does not cause this.

Connect to the local mail server and send
> From blah blah
> From blah blah

And you see in /var/mail/...
> >From blah blah
> From blah blah

Needless to say, this confuses practically everything handling mbox
files.

I'm not sure what eline was supposed to accomplish below, but it doesn't
seem to help since all 'From ' lines need to be escaped.

-- Martin

Index: mail.local.c
===================================================================
RCS file: /cvs/src/libexec/mail.local/mail.local.c,v
retrieving revision 1.33
diff -u -p -r1.33 mail.local.c
--- mail.local.c        16 Jan 2015 06:39:50 -0000      1.33
+++ mail.local.c        6 Feb 2015 15:00:13 -0000
@@ -117,7 +117,7 @@ storemail(char *from)
 {
        FILE *fp = NULL;
        time_t tval;
-       int fd, eline;
+       int fd;
        size_t len;
        char *line, *tbuf;
 
@@ -131,7 +131,7 @@ storemail(char *from)
        (void)time(&tval);
        (void)fprintf(fp, "From %s %s", from, ctime(&tval));
 
-       for (eline = 1, tbuf = NULL; (line = fgetln(stdin, &len));) {
+       for (tbuf = NULL; (line = fgetln(stdin, &len));) {
                /* We have to NUL-terminate the line since fgetln does not */
                if (line[len - 1] == '\n')
                        line[len - 1] = '\0';
@@ -143,14 +143,8 @@ storemail(char *from)
                        tbuf[len] = '\0';
                        line = tbuf;
                }
-               if (line[0] == '\0')
-                       eline = 1;
-               else {
-                       if (eline && line[0] == 'F' && len > 5 &&
-                           !memcmp(line, "From ", 5))
-                               (void)putc('>', fp);
-                       eline = 0;
-               }
+               if (line[0] == 'F' && len > 5 && !memcmp(line, "From ", 5))
+                       (void)putc('>', fp);
                (void)fprintf(fp, "%s\n", line);
                if (ferror(fp))
                        break;

Reply via email to