Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 May 1999 11:58:07 +1000
From:      Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>
To:        FreeBSD-gnats-submit@freebsd.org, sendmail-bugs@sendmail.ORG
Subject:   bin/11552: sendmail local delivery (mail.local) can't handle long lines
Message-ID:  <99May7.114652est.40861@border.alcanet.com.au>

next in thread | raw e-mail | index | archive | help

>Number:         11552
>Category:       bin
>Synopsis:       sendmail local delivery (mail.local) can't handle long lines
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May  6 19:10:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Peter Jeremy
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Alcatel Australia Limited
>Environment:

	Running -current from late April, (sendmail 8.9.3.1)

>Description:

	When a mail message includes lines longer than 2046 characters
	(in LMTP mode), mail.local will split the incoming line up into
	2046-character output lines (excluding the newline).  If an
	input line is 2047 characters long (excluding CRLF) and the last
	character is a '.', mail.local will see it as the end of input,
	transfer it to the user mailbox and try to write an `ok' back
	to sendmail.  If the message was much longer, both sendmail and
	mail.local will deadlock waiting for each other to read what
	they have written.

>How-To-Repeat:

	"echo make buildworld | batch" worked for my, but that is a fluke.
	Creating a message where one line contains 2046 characters followed
	by a single '.', followed by some other lines, delivered to a
	local user, should work.

>Fix:
	
Index: mail.local.c
===================================================================
RCS file: /home/CVSROOT/./src/contrib/sendmail/mail.local/mail.local.c,v
retrieving revision 1.6
diff -u -r1.6 mail.local.c
--- mail.local.c	1999/01/12 12:38:00	1.6
+++ mail.local.c	1999/05/07 01:22:44
@@ -602,7 +602,7 @@
 {
 	FILE *fp = NULL;
 	time_t tval;
-	int fd, eline;
+	int fd, eline, bline;
 	char line[2048];
 	char tmpbuf[sizeof _PATH_LOCTMP + 1];
 
@@ -627,32 +627,35 @@
 	(void)fprintf(fp, "From %s %s", from, ctime(&tval));
 
 	line[0] = '\0';
-	for (eline = 1; fgets(line, sizeof(line), stdin);) {
+	for (bline = eline = 1; fgets(line, sizeof(line), stdin);) {
 		size_t line_len = strlen(line);
 
 		if (line_len >= 2 &&
 		    line[line_len - 2] == '\r' &&
 		    line[line_len - 1] == '\n') {
-			strcpy(line + line_len - 2, "\n");
+			line[--line_len] = '\0';
+			line[line_len - 1] = '\n';
 		}
-		if (lmtprcpts && line[0] == '.') {
-			char *src = line + 1, *dest = line;
-
-			if (line[1] == '\n')
-				goto lmtpdot;
-			while (*src != '\0')
-				*dest++ = *src++;
-			*dest = '\0';
-		}
-		if (line[0] == '\n')
-			eline = 1;
-		else {
-			if (eline && line[0] == 'F' &&
-			    !memcmp(line, "From ", 5))
-				(void)putc('>', fp);
-			eline = 0;
+		if (bline) {
+			if (lmtprcpts && line[0] == '.') {
+				char *src = line + 1, *dest = line;
+
+				if (line[1] == '\n')
+					goto lmtpdot;
+				while (*src != '\0')
+					*dest++ = *src++;
+				*dest = '\0';
+			}
+			if (line[0] == '\n')
+				eline = 1;
+			else {
+				if (eline && line[0] == 'F' &&
+				    !memcmp(line, "From ", 5))
+					(void)putc('>', fp);
+				eline = 0;
+			}
 		}
-		(void)fprintf(fp, "%s", line);
+		(void)fputs(line, fp);
 		if (ferror(fp)) {
 			if (lmtprcpts) {
 				while (lmtprcpts--) {
@@ -667,6 +670,7 @@
 				exit(eval);
 			}
 		}
+		bline = (line[line_len - 1] == '\n');
 	}
 
 	if (lmtprcpts) {



>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99May7.114652est.40861>