Re: [PATCH v7 1/4] fs: unicode: Use strscpy() instead of strncpy()
From: Eric Biggers
Date: Wed Apr 07 2021 - 20:52:47 EST
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