diff options
author | Justin Stitt <justinstitt@google.com> | 2024-03-18 23:02:12 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-04-09 15:49:04 +0200 |
commit | da4e0ba419bb953fb8ae0aa4f85aef3febfbdf3e (patch) | |
tree | 40f60cef5358f600d03a11eb0c8c93521c7628b4 /drivers/tty/vt/conmakehash.c | |
parent | d78cc0df9d2b49ed7f87b46c7041aab1bce2995f (diff) |
tty: n_gsm: replace deprecated strncpy with strscpy
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.
We expect nc->if_name to be NUL-terminated based on existing manual
NUL-byte assignments and checks:
| nc.if_name[IFNAMSIZ-1] = '\0';
...
| if (nc->if_name[0] != '\0')
Let's use the new 2-argument strscpy() since it guarantees
NUL-termination on the destination buffer while correctly using the
destination buffers size to bound the operation.
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
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20240318-strncpy-drivers-tty-n_gsm-c-v1-1-da37a07c642e@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/conmakehash.c')
0 files changed, 0 insertions, 0 deletions