git: 8e2c2992da7a - main - socket_msg_trunc: allocate a large enough buffer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 Jan 2024 23:00:22 UTC
The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=8e2c2992da7aab7213b6349ff54dbaf1dcc05678 commit 8e2c2992da7aab7213b6349ff54dbaf1dcc05678 Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2024-01-09 19:35:37 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2024-01-09 22:59:29 +0000 socket_msg_trunc: allocate a large enough buffer Allocate 9000 bytes to match the largest requsted size. Add a check to prevent the list of sizes and buffer size from getting out of sync again. Reviewed by: markj Found with: CheriBSD Differential Revision: https://reviews.freebsd.org/D43340 --- tests/sys/kern/socket_msg_trunc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/sys/kern/socket_msg_trunc.c b/tests/sys/kern/socket_msg_trunc.c index ff0499c4540d..b0ea724f0de0 100644 --- a/tests/sys/kern/socket_msg_trunc.c +++ b/tests/sys/kern/socket_msg_trunc.c @@ -44,7 +44,7 @@ static void check_recvmsg(int cs, int ss, struct sockaddr *sa, const size_t sizes[], size_t nsizes) { - char buf[4096]; + char buf[9000]; memset(buf, 0xFF, sizeof(buf)); for (size_t i = 0; i < nsizes; i++) { @@ -52,6 +52,8 @@ check_recvmsg(int cs, int ss, struct sockaddr *sa, const size_t sizes[], size_t sz = sizes[i]; char tbuf[1]; + ATF_REQUIRE(sz <= sizeof(buf)); + rc = sendto(cs, buf, sz, 0, sa, sa->sa_len); ATF_REQUIRE_MSG(rc != -1, "sendto failed: %s", strerror(errno)); ATF_REQUIRE((size_t)rc == sz);