[PATCH mptcp-next v14 02/12] selftests: mptcp: sockopt: use exact length in connect_one_server
Geliang Tang <[email protected]> Thu, 30 Jul 2026 11:15:13 +0800
| Newsgroups | dev.linux.lists.mptcp |
|---|---|
| Message-ID | <6ec4570fb7b73f92905ef38beb414a4a7709e0a4.1785380422.git.tanggeliang@kylinos.cn> |
From: Geliang Tang <[email protected]> Use the exact remaining length ('len - total') when reading the echoed data from the socket, instead of the full buffer size. This silences a false positive -Wstringop-overflow warning from GCC, as the compiler can now prove that the destination buffer is large enough for the specified read size. connect_one_server() passes per-chunk 'ret' to do_getsockopts() instead of cumulative 'total', causing mismatches when the echo is fragmented. Fix by passing 'total' to match the semantics used in process_one_client(). Signed-off-by: Geliang Tang <[email protected]> --- tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c index 6c3d896d4a1b..469384823dc6 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -609,7 +609,7 @@ static void connect_one_server(int fd, int pipefd) total = 0; do { - ret = read(fd, buf2 + total, sizeof(buf2) - total); + ret = read(fd, buf2 + total, len - total); if (ret < 0) die_perror("read"); if (ret == 0) { @@ -629,7 +629,7 @@ static void connect_one_server(int fd, int pipefd) if (s.tcpi_rcv_delta) assert(s.tcpi_rcv_delta <= total); - do_getsockopts(&s, fd, ret, ret); + do_getsockopts(&s, fd, total, total); if (eof) total += 1; /* sequence advances due to FIN */ -- 2.53.0