Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Aug 2002 16:29:31 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        nate@root.org
Cc:        brooks@one-eyed-alien.net, arch@FreeBSD.ORG
Subject:   Re: kernel strlcpy
Message-ID:  <20020816.162931.25827842.imp@bsdimp.com>
In-Reply-To: <Pine.BSF.4.21.0208161522100.43853-100000@root.org>
References:  <20020816.141548.17599527.imp@bsdimp.com> <Pine.BSF.4.21.0208161522100.43853-100000@root.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <Pine.BSF.4.21.0208161522100.43853-100000@root.org>
            Nate Lawson <nate@root.org> writes:
: On Fri, 16 Aug 2002, M. Warner Losh wrote:
: > : I am not advocating introducing strlcat because strncat is bairly used
: > : (only 9 times in the whole kernel.)
: > 
: > I think it would be reasonable.
: > 
: > In fact, if we ELIMINATE strncat and strncpy in the kernel, then that
: > would be enough to justify bringing them in.  Since this isn't a
: > hosted environment, we can do that if we want.
: > 
: > Warner
: 
: One useful thing about strncpy is that it overwrites the remainder of its
: length with zeroes, not just null-terminating the string with a single
: zero.  This is useful for fixed-length fields that aren't interpreted as
: null-terminated strings but can be a huge performance hit when all you
: wanted was single null termination (i.e. path).

Right, but strn* is almost always used wrong.  There are very few
fixed length fields like this compared to the number of bogus useages
of strn*.

Warner

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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