]> git.baikalelectronics.ru Git - kernel.git/commit
net: qcom/emac: Replace strlcpy with strscpy
authorJason Wang <wangborong@cdjrlc.com>
Mon, 6 Sep 2021 13:56:53 +0000 (21:56 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Sep 2021 15:43:17 +0000 (16:43 +0100)
commit00b382e03523c36344a0e460aecdbe180adb0f21
treed6c5dd99173b30a79e948c53d549ab3c39aab83c
parent0f1e839e88e075725ac0eeab26c20b108586ebf0
net: qcom/emac: Replace strlcpy with strscpy

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: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c