mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 03:57:34 -04:00
myri10ge: use strscpy() to instead of strncpy()
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Xu Panda <xu.panda@zte.com.cn> Signed-off-by: Yang Yang <yang.yang29@zte.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
f6b759f56d
commit
a2d40ce7ac
@@ -552,8 +552,7 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp,
|
||||
}
|
||||
|
||||
/* save firmware version for ethtool */
|
||||
strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
|
||||
mgp->fw_version[sizeof(mgp->fw_version) - 1] = '\0';
|
||||
strscpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
|
||||
|
||||
sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
|
||||
&mgp->fw_ver_minor, &mgp->fw_ver_tiny);
|
||||
|
||||
Reference in New Issue
Block a user