Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Mar 2010 02:17:41 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Jaakko Heinonen <jh@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, "Andrey A. Chernov" <ache@FreeBSD.org>
Subject:   Re: svn commit: r204803 - head/usr.bin/uniq
Message-ID:  <20100308015926.O11669@delplex.bde.org>
In-Reply-To: <20100307104626.GA9015@a91-153-117-195.elisa-laajakaista.fi>
References:  <201003061921.o26JLv36014114@svn.freebsd.org> <20100307104626.GA9015@a91-153-117-195.elisa-laajakaista.fi>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100308015926.O11669>