summaryrefslogtreecommitdiffstats
path: root/net/mptcp/sockopt.c
diff options
context:
space:
mode:
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>2024-05-14 03:13:29 +0200
committerJakub Kicinski <kuba@kernel.org>2024-05-14 03:29:23 +0200
commit5eae7a8202f368a77ff0148729a9fa73cc24033a (patch)
treef33cc109811e609407169dc5deb3cd0054fb1d20 /net/mptcp/sockopt.c
parentmptcp: add net.mptcp.available_schedulers (diff)
downloadlinux-5eae7a8202f368a77ff0148729a9fa73cc24033a.tar.xz
linux-5eae7a8202f368a77ff0148729a9fa73cc24033a.zip
mptcp: prefer strscpy over strcpy
strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy() [1]. This is in preparation of a possible future step where all strcpy() uses will be removed in favour of strscpy() [2]. This fixes CheckPatch warnings: WARNING: Prefer strscpy over strcpy Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1] Link: https://github.com/KSPP/linux/issues/88 [2] Reviewed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Mat Martineau <martineau@kernel.org> Link: https://lore.kernel.org/r/20240514011335.176158-6-martineau@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/mptcp/sockopt.c')
-rw-r--r--net/mptcp/sockopt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index a77b33488176..f9a4fb17b5b7 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -616,7 +616,7 @@ static int mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t
}
if (ret == 0)
- strcpy(msk->ca_name, name);
+ strscpy(msk->ca_name, name, sizeof(msk->ca_name));
release_sock(sk);
return ret;