File: foo

package info (click to toggle)
socket-wrapper 1.2.1-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 612 kB
  • sloc: ansic: 9,262; sh: 58; makefile: 49
file content (51 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 src/socket_wrapper.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 0eff366..136b6d7 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3193,26 +3193,6 @@ static int swrap_accept(int s,
 #endif
 	}
 
-
-	/*
-	 * prevent parent_si from being altered / closed
-	 * while we read it
-	 */
-	SWRAP_LOCK_SI(parent_si);
-
-	/*
-	 * assume out sockaddr have the same size as the in parent
-	 * socket family
-	 */
-	in_addr.sa_socklen = socket_length(parent_si->family);
-	if (in_addr.sa_socklen <= 0) {
-		SWRAP_UNLOCK_SI(parent_si);
-		errno = EINVAL;
-		return -1;
-	}
-
-	SWRAP_UNLOCK_SI(parent_si);
-
 #ifdef HAVE_ACCEPT4
 	ret = libc_accept4(s, &un_addr.sa.s, &un_addr.sa_socklen, flags);
 #else
@@ -3230,6 +3210,16 @@ static int swrap_accept(int s,
 	fd = ret;
 
 	SWRAP_LOCK_SI(parent_si);
+	/*
+	 * assume out sockaddr have the same size as the in parent
+	 * socket family
+	 */
+	in_addr.sa_socklen = socket_length(parent_si->family);
+	if (in_addr.sa_socklen <= 0) {
+		SWRAP_UNLOCK_SI(parent_si);
+		errno = EINVAL;
+		return -1;
+	}
 
 	ret = sockaddr_convert_from_un(parent_si,
 				       &un_addr.sa.un,