chiark / gitweb /
Do not leak a harmless fd into the service program environment
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Dec 2021 01:11:01 +0000 (01:11 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Dec 2021 01:12:21 +0000 (01:12 +0000)
I have double-checked and this fd is the other end of a socketpair
that the server closes immediately after it reads our byte, so this is
indeed purely a harmless leak.

Closes: #864876
Reported-by: Ben Harris <bjh21@cam.ac.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
servexec.c

index 5fa8e1f3787babb29de15abf783a495cfbb4f450..6b55ea7b730c8c287a7cf1e49b1a77307ac3bbf4 100644 (file)
@@ -250,6 +250,7 @@ void execservice(const int synchsocket[], int clientfd) {
   if (r!=1) serv_syscallfail("write synch byte to parent");
   r= synchread(synchsocket[1],'g');
   if (r) serv_syscallfail("reach synch byte from parent");
+  if (close(synchsocket[1])) serv_syscallfail("close our synch socket");
 
   if (close(clientfd)) serv_syscallfail("close client socket fd");