aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2023-11-30 16:30:55 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2023-11-30 16:30:55 +0000
commitcfb1e92912b4cf75360b7fbe86197cc29bc212c1 (patch)
tree531725821c9f0e9e65e44ef3e0f5e77002d4d359 /tests
parent34c45bc6a3940ccfddb60207cb103f73bf87c4a6 (diff)
downloadsrc-cfb1e92912b4cf75360b7fbe86197cc29bc212c1.tar.gz
src-cfb1e92912b4cf75360b7fbe86197cc29bc212c1.zip
sockets: don't malloc/free sockaddr memory on accept(2)
Let the accept functions provide stack memory for protocols to fill it in. Generic code should provide sockaddr_storage, specialized code may provide smaller structure. While rewriting accept(2) make 'addrlen' a true in/out parameter, reporting required length in case if provided length was insufficient. Our manual page accept(2) and POSIX don't explicitly require that, but one can read the text as they do. Linux also does that. Update tests accordingly. Reviewed by: rscheff, tuexen, zlei, dchagin Differential Revision: https://reviews.freebsd.org/D42635
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/kern/socket_accept.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/tests/sys/kern/socket_accept.c b/tests/sys/kern/socket_accept.c
index 278eb2fb9853..24c3210900d6 100644
--- a/tests/sys/kern/socket_accept.c
+++ b/tests/sys/kern/socket_accept.c
@@ -81,10 +81,7 @@ ATF_TC_BODY(tcp4_zerolen, tc)
salen = 0;
ATF_REQUIRE(accept(l, (struct sockaddr *)&ret, &salen) > 0);
ATF_REQUIRE(memcmp(&ret, &canary, sizeof(ret)) == 0);
-#if 0
- /* Linux behavior. Matches my reading of accept(2) and POSIX. */
ATF_REQUIRE(salen == sizeof(struct sockaddr_in));
-#endif
/* Note: Linux will block for connection here, we fail immediately. */
ATF_REQUIRE(accept(l, (struct sockaddr *)&ret, NULL) == -1);
ATF_REQUIRE(errno == EFAULT);