[PATCH 14/15] xkb: Use memcpy for copy
Mark Kettenis
mark.kettenis at xs4all.nl
Wed Jul 28 02:48:28 PDT 2010
> Date: Wed, 28 Jul 2010 09:25:10 +1000
> From: Peter Hutterer <peter.hutterer at who-t.net>
>
> On Tue, Jul 27, 2010 at 03:09:55PM +0300, Pauli Nieminen wrote:
> > Source and destination have well defined size so use memcpy instead of
> > strncpy. strncpy tryes to add NULL to end of destination but it is not
> ^ "tries"
> > possible if source doesn't have NULL.
>
> my strncpy man page claims that if there is "no null byte among the first n
> bytes of src, the string placed in dest will not be null terminated." That's
> counter to what the message above says.
That's correct. It's why strlcpy(3) was invented in the non-Linux
world; strlcpy(3) guarantees that the copied string is
null-terminated.
So I agree with Peter that this change doesn't make a lot of sense.
Potentially strncpy(3) will be faster than memcpy(3) since it will
stop copying after a null character.
More information about the xorg-devel
mailing list