Re: [PATCH] isdnloop: NUL-terminate strings from userspace

From
David Miller <davem@davemloft.net>
Date
2014-04-01 20:18:41
Also in
lkml, stable
Reply to
Dan Carpenter, 2014-04-01
From: Dan Carpenter <redacted>
Date: Tue, 1 Apr 2014 15:35:34 +0300
I don't understand what you think the point of strlcpy() is, if it's not
to deal with source strings which aren't NUL terminated.
If strlcpy() is meant to handle non-NULL terminated strings, then it's
kernel doc needs to be adjusted.

/**
 * strlcpy - Copy a %NUL terminated string into a sized buffer
 * @dest: Where to copy the string to
 * @src: Where to copy the string from
 * @size: size of destination buffer
 *
 * Compatible with *BSD: the result is always a valid
 * NUL-terminated string that fits in the buffer (unless,
 * of course, the buffer size is zero). It does not pad
 * out the result like strncpy() does.
 */

That says to me that 'src' is expected to be NULL terminated.

Furthermore, I like YOSHIFUJI Hideaki's idea that we should
actually validate the string and return -EINVAL if it is not
given to us NULL terminated.
Thread (10 messages) 10 messages, 6 authors, last reply 2014-04-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help