Re: [PATCH v7 1/4] fs: unicode: Use strscpy() instead of strncpy()

From
Eric Biggers <ebiggers@kernel.org>
Date
2021-04-08 00:52:37
Also in
linux-f2fs-devel, linux-fsdevel, lkml
Reply to
Shreeya Patel, 2021-04-07
On Wed, Apr 07, 2021 at 08:18:42PM +0530, Shreeya Patel wrote:
The -Wstringop-truncation warning highlights the unintended
uses of the strncpy function that truncate the terminating NULL
character from the source string.
Unlike strncpy(), strscpy() always null-terminates the destination string,
hence use strscpy() instead of strncpy().
This explanation is a bit misleading.  It would be clearer to phrase this in
terms of fixing how overly-long strings are handled: start returning an error
instead of creating a non-null-terminated string.
Fixes: 9d53690f0d4e5 (unicode: implement higher level API for string handling)
There should be quotes around the commit title here.

- Eric
Thread (7 messages) 7 messages, 2 authors, last reply 2021-04-08
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