riscv: use strscpy to replace strlcpy
authorJason Wang <wangborong@cdjrlc.com>
Sat, 7 Aug 2021 07:14:27 +0000 (15:14 +0800)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Thu, 26 Aug 2021 04:52:47 +0000 (21:52 -0700)
commit803930ee35fafd005fd978d0c0a0d8db5bcba654
tree6ed4d86b8b656975f8505341316490633d5360df
parentfde9c59aebafb91caeed816cc510b56f14aa63ae
riscv: use strscpy to replace strlcpy

The strlcpy should not be used because it doesn't limit the source
length. As linus says, it's a completely useless function if you
can't implicitly trust the source string - but that is almost always
why people think they should use it! All in all the BSD function
will lead some potential bugs.

But the strscpy doesn't require reading memory from the src string
beyond the specified "count" bytes, and since the return value is
easier to error-check than strlcpy()'s. In addition, the implementation
is robust to the string changing out from underneath it, unlike the
current strlcpy() implementation.

Thus, We prefer using strscpy instead of strlcpy.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/kernel/setup.c