diff --git a/CHANGES b/CHANGES index 0588136..6c005c4 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,10 @@ Corrections: Partial write situations respect total inactivity timeout when nonblocking. + Fixed a bug that could lead to error "xiopoll(...): Bad file descriptor" + or to undefined behaviour before terminating Socat with addresses EXEC, + SYSTEM, or SHELL. + Building: Disabling certain features during configure could break build process. diff --git a/socat.c b/socat.c index c990f62..5886a00 100644 --- a/socat.c +++ b/socat.c @@ -865,11 +865,12 @@ int childleftdata(xiofile_t *xfd) { XIO_RDSTREAM(xfd)->para.exec.pid == 0) { struct timeval timeout = { 0, 0 }; - if (XIO_READABLE(xfd) && !(XIO_RDSTREAM(xfd)->eof >= 2 && !XIO_RDSTREAM(xfd)->ignoreeof)) { - in.fd = XIO_GETRDFD(xfd); - in.events = POLLIN/*|POLLRDBAND*/; - in.revents = 0; - } + if (XIO_RDSTREAM(xfd)->eof >= 2 && !XIO_RDSTREAM(xfd)->ignoreeof) + return 0; + + in.fd = XIO_GETRDFD(xfd); + in.events = POLLIN/*|POLLRDBAND*/; + in.revents = 0; do { int _errno; retval = xiopoll(&in, 1, &timeout); @@ -877,7 +878,7 @@ int childleftdata(xiofile_t *xfd) { } while (retval < 0 && errno == EINTR); if (retval < 0) { - Error5("xiopoll({%d,%0o}, 1, {"F_tv_sec"."F_tv_usec"}): %s", + Error5("xiopoll({%d,0%o}, 1, {"F_tv_sec"."F_tv_usec"}): %s", in.fd, in.events, timeout.tv_sec, timeout.tv_usec, strerror(errno)); return -1; @@ -1133,7 +1134,7 @@ int _socat(void) { */ if (retval < 0) { - Error11("xiopoll({%d,%0o}{%d,%0o}{%d,%0o}{%d,%0o}, 4, {"F_tv_sec"."F_tv_usec"}): %s", + Error11("xiopoll({%d,0%o}{%d,0%o}{%d,0%o}{%d,0%o}, 4, {"F_tv_sec"."F_tv_usec"}): %s", fds[0].fd, fds[0].events, fds[1].fd, fds[1].events, fds[2].fd, fds[2].events, fds[3].fd, fds[3].events, timeout.tv_sec, timeout.tv_usec, strerror(errno));