Skip to content

Commit 0a83299

Browse files
Jason Wangdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fe63339 commit 0a83299

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/qualcomm/emac/emac-ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void emac_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
100100

101101
case ETH_SS_STATS:
102102
for (i = 0; i < EMAC_STATS_LEN; i++) {
103-
strlcpy(data, emac_ethtool_stat_strings[i],
103+
strscpy(data, emac_ethtool_stat_strings[i],
104104
ETH_GSTRING_LEN);
105105
data += ETH_GSTRING_LEN;
106106
}

0 commit comments

Comments
 (0)