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)
commite47ba9f0c364c577be35a2cc155d90078742a2d7 (patch)
treec23059bb4f6b4076f0aa8e67bba7d045b989ff17 /win
parent6b29f7ffb2085eaed16ebd067696a80b8c770f5f (diff)
downloadtcl-e47ba9f0c364c577be35a2cc155d90078742a2d7.zip
tcl-e47ba9f0c364c577be35a2cc155d90078742a2d7.tar.gz
tcl-e47ba9f0c364c577be35a2cc155d90078742a2d7.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));
}
}