diff options
author | Justin Stitt <justinstitt@google.com> | 2023-10-11 01:32:35 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-10-14 02:28:35 +0300 |
commit | e3bbab4754dec801cefdd1b55920aff1bffac09d (patch) | |
tree | 3920f4fad35794b51d20584fea624b125fcd004a /drivers/isdn | |
parent | cf8b49fbd0418168b55c807b7fb62d7031026183 (diff) | |
download | linux-e3bbab4754dec801cefdd1b55920aff1bffac09d.tar.xz |
net: dsa: vsc73xx: replace deprecated strncpy with ethtool_sprintf
`strncpy` is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.
ethtool_sprintf() is designed specifically for get_strings() usage.
Let's replace strncpy in favor of this more robust and easier to
understand interface.
This change could result in misaligned strings when if(cnt) fails. To
combat this, use ternary to place empty string in buffer and properly
increment pointer to next string slot.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231010-strncpy-drivers-net-dsa-vitesse-vsc73xx-core-c-v2-1-ba4416a9ff23@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/isdn')
0 files changed, 0 insertions, 0 deletions