aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorimorgenstern <igor.morgenstern@aisle.com>2025-08-28 13:42:04 +0200
committerGitHub <noreply@github.com>2025-08-28 13:42:04 +0200
commitd7a9ca6d2ffdfd65543c32b6f11a8a106e839d81 (patch)
tree410c8206910d08d3844470863129b63db1c0f14f
parentcf1a8cf5ba0aa8ff57362c1933318f6b8d9fbd12 (diff)
downloadportable-d7a9ca6d2ffdfd65543c32b6f11a8a106e839d81.tar.gz
portable-d7a9ca6d2ffdfd65543c32b6f11a8a106e839d81.tar.bz2
portable-d7a9ca6d2ffdfd65543c32b6f11a8a106e839d81.zip
Fix inconsistencies in accept4.c
Fix inconsistencies in accept4.c. If the underlying accept() fails the shim returns the listening socket s instead of −1.
-rw-r--r--apps/nc/compat/accept4.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/nc/compat/accept4.c b/apps/nc/compat/accept4.c
index 278198b..dca42e9 100644
--- a/apps/nc/compat/accept4.c
+++ b/apps/nc/compat/accept4.c
@@ -6,10 +6,10 @@ accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
6{ 6{
7 int rets = accept(s, addr, addrlen); 7 int rets = accept(s, addr, addrlen);
8 if (rets == -1) 8 if (rets == -1)
9 return s; 9 return rets;
10 10
11 if (flags & SOCK_CLOEXEC) { 11 if (flags & SOCK_CLOEXEC) {
12 flags = fcntl(s, F_GETFD); 12 flags = fcntl(rets, F_GETFD);
13 fcntl(rets, F_SETFD, flags | FD_CLOEXEC); 13 fcntl(rets, F_SETFD, flags | FD_CLOEXEC);
14 } 14 }
15 15