coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] [PATCH] sort: fix bug in --debug when \0 is followed by


From: Paul Eggert
Subject: Re: [coreutils] [PATCH] sort: fix bug in --debug when \0 is followed by \t
Date: Sun, 08 Aug 2010 23:53:27 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

On 08/08/10 17:41, Pádraig Brady wrote:
> Are there other reasons for not using strnlen()
> apart from it not dealing with NULs in the input?

Generally speaking, a data structure where
strnlen makes sense is a data structure that
is probably poorly designed.  strnlen was
originally designed for the likes of Unix
Version 7 directory entries, which had 14
bytes for the name and 2 bytes for the inode
number, where names were limited to 14 bytes
in length, and where they didn't want to insist
on null-terminated names (and therefore limit
the name length to 13 bytes, to keep inode sizes
a power of two).

GNU code is not supposed to have silly limits like
that, and unless it's dealing with externally-designed
data structures that resemble V7 inode entries, it
shouldn't need strnlen.

Also, strnlen is confusing.

strncpy is even worse.  Don't get me started on strncpy!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]