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.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"