From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 14 04:10:19 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4FC1216A4CE for ; Fri, 14 Nov 2003 04:10:19 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B949E43FB1 for ; Fri, 14 Nov 2003 04:10:17 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id hAECAHFY015349 for ; Fri, 14 Nov 2003 04:10:17 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id hAECAHSt015348; Fri, 14 Nov 2003 04:10:17 -0800 (PST) (envelope-from gnats) Resent-Date: Fri, 14 Nov 2003 04:10:17 -0800 (PST) Resent-Message-Id: <200311141210.hAECAHSt015348@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andrey Beresovsky Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4A33716A4CE for ; Fri, 14 Nov 2003 04:07:55 -0800 (PST) Received: from moon.cc.rsu.ru (moon.cc.rsu.ru [195.208.252.124]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF97243FA3 for ; Fri, 14 Nov 2003 04:07:53 -0800 (PST) (envelope-from and@moon.cc.rsu.ru) Received: from moon.cc.rsu.ru (localhost [127.0.0.1]) by moon.cc.rsu.ru (8.12.9/8.12.9) with ESMTP id hAEC7pFH001272; Fri, 14 Nov 2003 15:07:51 +0300 (MSK) (envelope-from and@moon.cc.rsu.ru) Received: (from and@localhost) by moon.cc.rsu.ru (8.12.9/8.12.9/Submit) id hAEC7oeq001271; Fri, 14 Nov 2003 15:07:50 +0300 (MSK) Message-Id: <200311141207.hAEC7oeq001271@moon.cc.rsu.ru> Date: Fri, 14 Nov 2003 15:07:50 +0300 (MSK) From: Andrey Beresovsky To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: os@rsu.ru Subject: bin/59285: [PATCH] /usr/libexec/ftpd has broken ASCII transfer type implementation X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Andrey Beresovsky List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2003 12:10:19 -0000 >Number: 59285 >Category: bin >Synopsis: [PATCH] /usr/libexec/ftpd has broken ASCII transfer type implementation >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Nov 14 04:10:16 PST 2003 >Closed-Date: >Last-Modified: >Originator: Andrey Beresovsky >Release: FreeBSD 5.1-CURRENT i386 >Organization: Rostov State University >Environment: System: FreeBSD 5.1-CURRENT #2: Fri Nov 7 22:15:49 MSK 2003 i386 >Description: According to RFC 959 (FILE TRANSFER PROTOCOL) for ASCII transfer type "the sequence should be used where necessary to denote the end of a line of text" (Chapter 3.1.1.1.). ftpd server implements ASCII transfer type by inserting before each without checking that may be allready exists. It leads to sequences in files which allready had end of lines (ex.: text files from Windows systems). Attached patch should fix this problem. This problem also exists in lukemftp and lukemftpd. I sent PR with patches to NetBSD. See http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=23435. >How-To-Repeat: 1. Create a text file with end of lines. 2. Receive (GET) this file from FreeBSD ftpd server. 3. You'll get a file with EOLs on windows and on unixes. >Fix: (ftpd.c rev. 1.146) --- ftpd.c.orig Thu Nov 13 23:29:54 2003 +++ ftpd.c Thu Nov 13 23:33:14 2003 @@ -1971,6 +1971,7 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg) { int c, filefd, netfd; + int d = '\0'; char *buf; off_t cnt; @@ -1982,12 +1983,13 @@ if (recvurg) goto got_oob; byte_count++; - if (c == '\n') { + if (c == '\n' && d != '\r') { if (ferror(outstr)) goto data_err; (void) putc('\r', outstr); } (void) putc(c, outstr); + d = c; } if (recvurg) goto got_oob; >Release-Note: >Audit-Trail: >Unformatted: