Fixed an internal FD leak in the EXEC,SYSTEM addresses

This commit is contained in:
Gerhard Rieger 2023-06-12 12:21:09 +02:00
parent 10a741eb60
commit 8539e6e887
2 changed files with 6 additions and 4 deletions

View file

@ -32,6 +32,8 @@ Corrections:
/dev/vsock. /dev/vsock.
Thanks to Volker Simonis for sending a patch. Thanks to Volker Simonis for sending a patch.
Fixed an internal FD leak in the EXEC,SYSTEM addresses.
Features: Features:
VSOCK, VSOCK-L support options pf, socktype, prototype (currently VSOCK, VSOCK-L support options pf, socktype, prototype (currently
useless) useless)

View file

@ -75,7 +75,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
bool nofork = false; bool nofork = false;
bool withfork; bool withfork;
char *tn = NULL; char *tn = NULL;
int trigger[2]; int trigger[2]; /* [0] watched by parent, [1] closed by child when ready */
popts = moveopts(*copts, GROUP_ALL); popts = moveopts(*copts, GROUP_ALL);
if (applyopts_single(fd, popts, PH_INIT) < 0) return -1; if (applyopts_single(fd, popts, PH_INIT) < 0) return -1;
@ -391,11 +391,11 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
} }
if (!withfork || pid == 0) { /* child */ if (!withfork || pid == 0) { /* child */
if (withfork) { if (withfork) {
Close(trigger[0]); /* in child: not needed here */
/* The child should have default handling for SIGCHLD. */ /* The child should have default handling for SIGCHLD. */
/* In particular, it's not defined whether ignoring SIGCHLD is inheritable. */ /* In particular, it's not defined whether ignoring SIGCHLD is inheritable. */
if (Signal(SIGCHLD, SIG_DFL) == SIG_ERR) { if (Signal(SIGCHLD, SIG_DFL) == SIG_ERR) {
Warn1("signal(SIGCHLD, SIG_DFL): %s", strerror(errno)); Warn1("signal(SIGCHLD, SIG_DFL): %s", strerror(errno));
Close(trigger[0]);
} }
#if HAVE_PTY #if HAVE_PTY
@ -546,7 +546,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
} }
if (withfork) { if (withfork) {
Info("Signalling parent ready"); Info("Signalling parent ready");
Close(trigger[1]); Close(trigger[1]); /* in child, notify parent that ready */
} }
} /* withfork */ } /* withfork */
else { else {
@ -565,7 +565,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
/* for parent (this is our socat process) */ /* for parent (this is our socat process) */
Notice1("forked off child process "F_pid, pid); Notice1("forked off child process "F_pid, pid);
Close(trigger[1]); Close(trigger[1]); /* in parent */
#if 0 #if 0
if ((popts = copyopts(*copts, if ((popts = copyopts(*copts,