Skip to content

Commit 53f2241

Browse files
author
git-core
committed
Set close-on-exec for the socket
An attacker could access the communication channel between su and Superuser otherwise.
1 parent f09ab43 commit 53f2241

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

su.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ static int socket_create_temp(char *path, size_t len)
169169
PLOGE("socket");
170170
return -1;
171171
}
172+
if (fcntl(fd, F_SETFD, FD_CLOEXEC)) {
173+
PLOGE("fcntl FD_CLOEXEC");
174+
goto err;
175+
}
172176

173177
memset(&sun, 0, sizeof(sun));
174178
sun.sun_family = AF_LOCAL;

0 commit comments

Comments
 (0)