зеркало из https://github.com/mozilla/pjs.git
Bugzilla bug 106496: fixed the WINNT version of PR_NewTCPSocketPair to
verify the source of the connection.
This commit is contained in:
Родитель
1b36216be7
Коммит
3ea7927fd3
|
@ -1385,7 +1385,7 @@ PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *f[])
|
||||||
*/
|
*/
|
||||||
SOCKET listenSock;
|
SOCKET listenSock;
|
||||||
SOCKET osfd[2];
|
SOCKET osfd[2];
|
||||||
struct sockaddr_in selfAddr;
|
struct sockaddr_in selfAddr, peerAddr;
|
||||||
int addrLen;
|
int addrLen;
|
||||||
|
|
||||||
if (!_pr_initialized) _PR_ImplicitInitialization();
|
if (!_pr_initialized) _PR_ImplicitInitialization();
|
||||||
|
@ -1429,10 +1429,24 @@ PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *f[])
|
||||||
addrLen) == SOCKET_ERROR) {
|
addrLen) == SOCKET_ERROR) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
osfd[1] = accept(listenSock, NULL, NULL);
|
/*
|
||||||
|
* A malicious local process may connect to the listening
|
||||||
|
* socket, so we need to verify that the accepted connection
|
||||||
|
* is made from our own socket osfd[0].
|
||||||
|
*/
|
||||||
|
if (getsockname(osfd[0], (struct sockaddr *) &selfAddr,
|
||||||
|
&addrLen) == SOCKET_ERROR) {
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
osfd[1] = accept(listenSock, (struct sockaddr *) &peerAddr, &addrLen);
|
||||||
if (osfd[1] == INVALID_SOCKET) {
|
if (osfd[1] == INVALID_SOCKET) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
if (peerAddr.sin_port != selfAddr.sin_port) {
|
||||||
|
/* the connection we accepted is not from osfd[0] */
|
||||||
|
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
closesocket(listenSock);
|
closesocket(listenSock);
|
||||||
|
|
||||||
f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods());
|
f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods());
|
||||||
|
|
Загрузка…
Ссылка в новой задаче