traceroute: fix help text to not show -6 when traceroute6 is off
[oweals/busybox.git] / mailutils / sendmail.c
index a216d66c1aabff1a68fd2dfcbc6581ceb143ed87..4b58a78eb062478bc9cc4c822b08bc3e64f9d3a7 100644 (file)
@@ -93,7 +93,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
 
        // save initial stdin since body is piped!
        xdup2(STDIN_FILENO, 3);
-       G.fp0 = fdopen(3, "r");
+       G.fp0 = xfdopen_for_read(3);
 
        // parse options
        // -f is required. -H and -S are mutually exclusive
@@ -229,10 +229,15 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
                        rcptto(sane_address(s+5));
                        free(s);
                        // N.B. Bcc: vanishes from headers!
+
                // other headers go verbatim
-               // N.B. we allow MAX_HEADERS generic headers at most to prevent attacks
-               } else if (strchr(s, ':')) {
+
+               // N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines.
+               // Continuation is denoted by prefixing additional lines with whitespace(s).
+               // Thanks (stefan.seyfried at googlemail.com) for pointing this out.
+               } else if (strchr(s, ':') || (list && skip_whitespace(s) != s)) {
  addheader:
+                       // N.B. we allow MAX_HEADERS generic headers at most to prevent attacks
                        if (MAX_HEADERS && ++nheaders >= MAX_HEADERS)
                                goto bail;
                        llist_add_to_end(&list, s);