git: 1a0dde338df8 - main - dma: limit lines to 998 characters

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 28 Jan 2022 15:06:27 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a0dde338df8b493d74dcb2f7bbaaa6c02cab371

commit 1a0dde338df8b493d74dcb2f7bbaaa6c02cab371
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-01-28 14:57:44 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-01-28 15:02:43 +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
---
 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;