git: 5c1ee92b0eba - stable/12 - dma: limit lines to 998 characters

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sat, 05 Feb 2022 16:27:29 UTC
The branch stable/12 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=5c1ee92b0ebab49577d065baf7f37a8ffcde4259

commit 5c1ee92b0ebab49577d065baf7f37a8ffcde4259
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-01-28 14:57:44 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-02-05 16:26:42 +0000

    dma: limit lines to 998 characters
    
    Per RFC2822 the maximum transmitted line length is "998 characters...
    excluding the CRLF."  In a file the maximum is 999 with the \n included.
    
    Previously mail containing a line with exactly 999 characters would
    bounce.
    
    PR:             208261
    Reported by:    Helge Oldach
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 1a0dde338df8b493d74dcb2f7bbaaa6c02cab371)
---
 contrib/dma/mail.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/dma/mail.c b/contrib/dma/mail.c
index 48c8ee6d4dd2..9e00c22d71db 100644
--- a/contrib/dma/mail.c
+++ b/contrib/dma/mail.c
@@ -43,7 +43,7 @@
 
 #include "dma.h"
 
-#define MAX_LINE_RFC822	1000
+#define MAX_LINE_RFC822	999 /* 998 characters plus \n */
 
 void
 bounce(struct qitem *it, const char *reason)
@@ -378,7 +378,7 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
 	char *line = NULL;
 	ssize_t linelen;
 	size_t linecap = 0;
-	char newline[MAX_LINE_RFC822];
+	char newline[MAX_LINE_RFC822 + 1];
 	size_t error;
 	int had_headers = 0;
 	int had_from = 0;