From owner-svn-src-all@FreeBSD.ORG Sun Mar 7 15:17:45 2010 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18CCF106564A; Sun, 7 Mar 2010 15:17:45 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by mx1.freebsd.org (Postfix) with ESMTP id 866118FC1D; Sun, 7 Mar 2010 15:17:44 +0000 (UTC) Received: from c122-106-145-171.carlnfd1.nsw.optusnet.com.au (c122-106-145-171.carlnfd1.nsw.optusnet.com.au [122.106.145.171]) by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o27FHfDs013475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 8 Mar 2010 02:17:42 +1100 Date: Mon, 8 Mar 2010 02:17:41 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Jaakko Heinonen In-Reply-To: <20100307104626.GA9015@a91-153-117-195.elisa-laajakaista.fi> Message-ID: <20100308015926.O11669@delplex.bde.org> References: <201003061921.o26JLv36014114@svn.freebsd.org> <20100307104626.GA9015@a91-153-117-195.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, "Andrey A. Chernov" Subject: Re: svn commit: r204803 - head/usr.bin/uniq X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2010 15:17:45 -0000 On Sun, 7 Mar 2010, Jaakko Heinonen wrote: > On 2010-03-06, Andrey A. Chernov wrote: >> >> 3) Enforce the implied LINE_MAX limit (from POSIX definition of "text file" >> and POSIX uniq(1) description). This seems to enforce a limit of LINE_MAX - 1, since space for the NUL terminator is no longer provided. Hopfully there is no buffer overrun from this. > Although a file with lines longer than LINE_MAX isn't a text file by > POSIX definition I don't think that POSIX requires uniq(1) to reject > non-POSIX text files. Thus I would like to keep the support for longer > lines. There was a long discussion about this in the Opengroup list recently. An example in POSIX has an off-by-2 error instead of the above off-by-1 error, since its buffer size is only LINE_MAX and it loses an extra 1 by putting the terminating newline in the buffer. The example is also bad in using LINE_MAX, since {LINE_MAX} is not necessarily constant. Dynamic allocation is required to use sysconf(__SC_LINE_MAX) and once you do that it is almost as easy to support arbitrary line lengths like FreeBSD used to. Old versions of FreeBSD didn't have any of the dynamic allocation, or the off-by-1 error, or the new (as I remember) error handling of aborting for long lines; they silently discarded characters after the LINE_MAX'th one. Bruce.