mirror of
https://github.com/reactos/reactos.git
synced 2025-05-08 11:24:14 +00:00
- Keep waiting for a reply if we get one that is not ours or invalid
- Make sure the packet we got is from our target otherwise discard it svn path=/trunk/; revision=42356
This commit is contained in:
parent
b85fb3bd9f
commit
3ced893fd0
1 changed files with 36 additions and 32 deletions
|
@ -437,6 +437,14 @@ static BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (from->sin_addr.s_addr != Target.sin_addr.s_addr)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
printf("Bad source address (%s should be %s)\n", inet_ntoa(from->sin_addr), inet_ntoa(Target.sin_addr));
|
||||
#endif /* !NDEBUG */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
QueryTime(&LargeTime);
|
||||
|
||||
RelativeTime.QuadPart = (LargeTime.QuadPart - Icmp->Timestamp.QuadPart);
|
||||
|
@ -543,6 +551,7 @@ static BOOL Ping(VOID)
|
|||
Timeval.tv_sec = Timeout / 1000;
|
||||
Timeval.tv_usec = Timeout % 1000;
|
||||
|
||||
do {
|
||||
Status = select(0, &Fds, NULL, NULL, &Timeval);
|
||||
if ((Status != SOCKET_ERROR) && (Status != 0))
|
||||
{
|
||||
|
@ -575,12 +584,7 @@ static BOOL Ping(VOID)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (!DecodeResponse(Buffer, Status, (PSOCKADDR_IN)&From))
|
||||
{
|
||||
/* FIXME: Wait again as it could be another ICMP message type */
|
||||
printf("Request timed out (incomplete datagram received).\n");
|
||||
LostCount++;
|
||||
}
|
||||
} while (!DecodeResponse(Buffer, Status, (PSOCKADDR_IN)&From));
|
||||
|
||||
GlobalFree(Buffer);
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue