From owner-freebsd-bugs Thu May 6 19:10: 5 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 540781500F for ; Thu, 6 May 1999 19:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id TAA09252; Thu, 6 May 1999 19:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from alcanet.com.au (border.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id 90EC514CFD for ; Thu, 6 May 1999 19:04:04 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <40861>; Fri, 7 May 1999 11:46:52 +1000 Message-Id: <99May7.114652est.40861@border.alcanet.com.au> Date: Fri, 7 May 1999 11:58:07 +1000 From: Peter Jeremy Reply-To: peter.jeremy@alcatel.com.au To: FreeBSD-gnats-submit@freebsd.org, sendmail-bugs@sendmail.ORG X-Send-Pr-Version: 3.2 Subject: bin/11552: sendmail local delivery (mail.local) can't handle long lines Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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