1
0
mirror of https://github.com/moparisthebest/socat synced 2024-12-22 06:58:47 -05:00

merged fix for possible SIGSEGV in listening addresses

This commit is contained in:
Gerhard Rieger 2009-03-31 23:18:56 +02:00
commit a5591dcfd0
3 changed files with 16 additions and 9 deletions

View File

@ -1,5 +1,9 @@
corrections: corrections:
fixed possible SIGSEGV in listening addresses when a new connection was
reset by peer before the socket addresses could be retrieved. Thanks to
Mike Perry for sending a patch.
fixed a bug, introduced with version 1.7.0.0, that let client fixed a bug, introduced with version 1.7.0.0, that let client
connections with option connect-timeout fail when the connections connections with option connect-timeout fail when the connections
succeeded. Thanks to Bruno De Fraine for reporting this bug. succeeded. Thanks to Bruno De Fraine for reporting this bug.

View File

@ -1 +1 @@
"1.7.0.0+execshut+connecttimeout" "1.7.0.0+execshut+connecttimeout+segvonaccept"

View File

@ -1,5 +1,5 @@
/* source: xio-listen.c */ /* source: xio-listen.c */
/* Copyright Gerhard Rieger 2001-2008 */ /* Copyright Gerhard Rieger 2001-2009 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for listen socket options */ /* this file contains the source for listen socket options */
@ -254,8 +254,10 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
la = NULL; la = NULL;
} }
Notice2("accepting connection from %s on %s", Notice2("accepting connection from %s on %s",
sockaddr_info(pa?&pa->soa:NULL, pas, peername, sizeof(peername)), pa?
sockaddr_info(pa?&la->soa:NULL, las, sockname, sizeof(sockname))); sockaddr_info(&pa->soa, pas, peername, sizeof(peername)):"NULL",
la?
sockaddr_info(&la->soa, las, sockname, sizeof(sockname)):"NULL");
if (pa != NULL && la != NULL && xiocheckpeer(xfd, pa, la) < 0) { if (pa != NULL && la != NULL && xiocheckpeer(xfd, pa, la) < 0) {
if (Shutdown(ps, 2) < 0) { if (Shutdown(ps, 2) < 0) {
@ -264,9 +266,10 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
continue; continue;
} }
Info1("permitting connection from %s", if (pa != NULL)
sockaddr_info((struct sockaddr *)pa, pas, Info1("permitting connection from %s",
infobuff, sizeof(infobuff))); sockaddr_info((struct sockaddr *)pa, pas,
infobuff, sizeof(infobuff)));
applyopts(xfd->fd, opts, PH_FD); applyopts(xfd->fd, opts, PH_FD);
applyopts(xfd->fd, opts, PH_CONNECTED); applyopts(xfd->fd, opts, PH_CONNECTED);
@ -322,8 +325,8 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
return result; return result;
/* set the env vars describing the local and remote sockets */ /* set the env vars describing the local and remote sockets */
xiosetsockaddrenv("SOCK", la, las, proto); if (la != NULL) xiosetsockaddrenv("SOCK", la, las, proto);
xiosetsockaddrenv("PEER", pa, pas, proto); if (pa != NULL) xiosetsockaddrenv("PEER", pa, pas, proto);
return 0; return 0;
} }