1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-06-10 11:46:50 +00:00

Fixed: xiopoll(...) Bad file descriptor

This commit is contained in:
Gerhard Rieger 2025-01-29 22:41:25 +01:00
parent 1154e69d3e
commit 9beffd3193
2 changed files with 12 additions and 7 deletions

View file

@ -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.

15
socat.c
View file

@ -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));