When /usr/libexec/validate_firmware_image is not present on the system
procd will hang indefinitely on the read() since the input side of the
pipe is still open.
Also fix pipe file descriptor leak when fork() fails.
Signed-off-by: Dustin Lundquist <d.lundquist@temperednetworks.com>
Acked-by: Rafał Miłecki <rafal@milecki.pl>
switch (fork()) {
case -1:
+ close(fds[0]);
+ close(fds[1]);
return -errno;
case 0:
/* Set stdin & stderr to /dev/null */
}
/* Parent process */
+ close(fds[1]);
tok = json_tokener_new();
if (!tok) {
close(fds[0]);
- close(fds[1]);
return -ENOMEM;
}
}
close(fds[0]);
- close(fds[1]);
err = -ENOENT;
if (jsobj) {