]> git.baikalelectronics.ru Git - kernel.git/commit
dpaa2-eth: Replace strlcpy with strscpy
authorJason Wang <wangborong@cdjrlc.com>
Mon, 30 Aug 2021 13:05:31 +0000 (21:05 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Aug 2021 10:30:53 +0000 (11:30 +0100)
commitedb8526654dcb9ab325dd7dc68c6c44f09a2bfd9
tree8bea1f0315137fa52e373c0cd24249a08f044fea
parentfd0522fb77b6d5d8e9d8ccd3957cf0f950fa1707
dpaa2-eth: 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/freescale/dpaa2/dpaa2-ethtool.c