Author: arty
Date: Mon Mar 16 23:59:05 2009
New Revision: 40067
URL:
http://svn.reactos.org/svn/reactos?rev=40067&view=rev
Log:
Fix some issues with peer names being reported. There may be other problems
too.
My read of MSDN is that queries that return addresses in queries other than
TDI_QUERY_ADDRESS_INFO return a TRANSPORT_ADDRESS, so we plumb that through
for GetPeerName. Note that this isn't user-facing functionality, so it's
unlikely, though not impossible, that we've got it wrong and it'll affect
something. Likely, this is an improvement.
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Mon Mar 16 23:59:05 2009
@@ -1488,7 +1488,7 @@
{
IO_STATUS_BLOCK IOSB;
ULONG TdiAddressSize;
- PTDI_ADDRESS_INFO TdiAddress;
+ PTDI_ADDRESS_INFO TdiAddress;
PTRANSPORT_ADDRESS SocketAddress;
PSOCKET_INFORMATION Socket = NULL;
NTSTATUS Status;
@@ -1507,9 +1507,8 @@
Socket = GetSocketStructure(Handle);
/* Allocate a buffer for the address */
- TdiAddressSize = FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
- Socket->SharedData.SizeOfLocalAddress;
-
+ TdiAddressSize =
+ sizeof(TRANSPORT_ADDRESS) + Socket->SharedData.SizeOfLocalAddress;
TdiAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize);
if ( TdiAddress == NULL )
@@ -1578,7 +1577,6 @@
{
IO_STATUS_BLOCK IOSB;
ULONG TdiAddressSize;
- PTDI_ADDRESS_INFO TdiAddress;
PTRANSPORT_ADDRESS SocketAddress;
PSOCKET_INFORMATION Socket = NULL;
NTSTATUS Status;
@@ -1597,19 +1595,16 @@
Socket = GetSocketStructure(s);
/* Allocate a buffer for the address */
- TdiAddressSize = FIELD_OFFSET(TDI_ADDRESS_INFO, Address.Address[0].Address) +
- Socket->SharedData.SizeOfLocalAddress;
- TdiAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize);
-
- if ( TdiAddress == NULL )
+ TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + *NameLength;
+ SocketAddress = HeapAlloc(GlobalHeap, 0, TdiAddressSize);
+
+ if ( SocketAddress == NULL )
{
NtClose( SockEvent );
*lpErrno = WSAENOBUFS;
return SOCKET_ERROR;
}
- SocketAddress = &TdiAddress->Address;
-
/* Send IOCTL */
Status = NtDeviceIoControlFile((HANDLE)Socket->Handle,
SockEvent,
@@ -1619,7 +1614,7 @@
IOCTL_AFD_GET_PEER_NAME,
NULL,
0,
- TdiAddress,
+ SocketAddress,
TdiAddressSize);
/* Wait for return */
@@ -1643,12 +1638,12 @@
AFD_DbgPrint (MID_TRACE, ("NameLength %d Address: %s Port %x\n",
*NameLength, ((struct sockaddr_in *)Name)->sin_addr.s_addr,
((struct sockaddr_in *)Name)->sin_port));
- HeapFree(GlobalHeap, 0, TdiAddress);
+ HeapFree(GlobalHeap, 0, SocketAddress);
return 0;
}
else
{
- HeapFree(GlobalHeap, 0, TdiAddress);
+ HeapFree(GlobalHeap, 0, SocketAddress);
*lpErrno = WSAEFAULT;
return SOCKET_ERROR;
}