summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authormax <max@tclers.tk>2012-07-19 10:54:13 (GMT)
committermax <max@tclers.tk>2012-07-19 10:54:13 (GMT)
commitd7b27b173d6263bcc5291dba4e78cd58905b19d4 (patch)
treec23059bb4f6b4076f0aa8e67bba7d045b989ff17 /win
parent9286aa68b6fd92900f055c27d18dacf052b6900e (diff)
downloadtcl-d7b27b173d6263bcc5291dba4e78cd58905b19d4.zip
tcl-d7b27b173d6263bcc5291dba4e78cd58905b19d4.tar.gz
tcl-d7b27b173d6263bcc5291dba4e78cd58905b19d4.tar.bz2
[Bug: 3545363]: Use a large enough buffer for accept()ing IPv6
connections. Fix conversion of host and port for passing to the accept proc to be independent of the IP version.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinSock.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 97b10a3..5603ef3 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -1556,18 +1556,19 @@ TcpAccept(
SOCKET newSocket;
SocketInfo *newInfoPtr;
SocketInfo *infoPtr = fds->infoPtr;
- SOCKADDR_IN addr;
+ address addr;
int len;
char channelName[16 + TCL_INTEGER_SPACE];
+ char host[NI_MAXHOST], port[NI_MAXSERV];
ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey);
/*
* Accept the incoming connection request.
*/
- len = sizeof(SOCKADDR_IN);
+ len = sizeof(address);
- newSocket = accept(fds->fd, (SOCKADDR *) &addr, &len);
+ newSocket = accept(fds->fd, &(addr.sa), &len);
/*
* Protect access to sockets (acceptEventCount, readyEvents) in socketList
@@ -1644,8 +1645,10 @@ TcpAccept(
*/
if (infoPtr->acceptProc != NULL) {
+ getnameinfo(&(addr.sa), len, host, sizeof(host), port, sizeof(port),
+ NI_NUMERICHOST|NI_NUMERICSERV);
infoPtr->acceptProc(infoPtr->acceptProcData, newInfoPtr->channel,
- inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
+ host, atoi(port));
}
}