Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit a3bfc095 authored by Kees Cook's avatar Kees Cook Committed by Jakub Kicinski
Browse files

tcp: Replace strncpy() with strscpy()

Replace the deprecated[1] uses of strncpy() in tcp_ca_get_name_by_key()
and tcp_get_default_congestion_control(). The callers use the results as
standard C strings (via nla_put_string() and proc handlers respectively),
so trailing padding is not needed.

Since passing the destination buffer arguments decays it to a pointer,
the size can't be trivially determined by the compiler. ca->name is
the same length in both cases, so strscpy() won't fail (when ca->name
is NUL-terminated). Include the length explicitly instead of using the
2-argument strscpy().

Link: https://github.com/KSPP/linux/issues/90

 [1]
Signed-off-by: default avatarKees Cook <kees@kernel.org>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240714041111.it.918-kees@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b49991d8
Branches
Tags
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment