Skip to content

Commit 6d9bb99

Browse files
committed
- Fix sending malformed ICMP packets because we read the wrong length from the wrong address in the buffer
- Fix the sequence number stored in the packet - Fix potential null pointer freeing - tracert partially works now (Setting TTL isn't implemented yet) svn path=/trunk/; revision=43732
1 parent fcb80fe commit 6d9bb99

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

reactos/base/applications/network/tracert/tracert.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ PreparePacket(PAPPINFO pInfo,
260260
pInfo->SendPacket->icmpheader.code = 0;
261261
pInfo->SendPacket->icmpheader.checksum = 0;
262262
pInfo->SendPacket->icmpheader.id = (USHORT)GetCurrentProcessId();
263-
pInfo->SendPacket->icmpheader.seq = iSeqNum;
263+
pInfo->SendPacket->icmpheader.seq = htons((USHORT)iSeqNum);
264264

265265
/* calculate checksum of packet */
266-
pInfo->SendPacket->icmpheader.checksum = CheckSum((PUSHORT)&pInfo->SendPacket,
266+
pInfo->SendPacket->icmpheader.checksum = CheckSum((PUSHORT)&pInfo->SendPacket->icmpheader,
267267
sizeof(ICMP_HEADER) + PACKET_SIZE);
268268
}
269269

@@ -279,8 +279,8 @@ SendPacket(PAPPINFO pInfo)
279279
pInfo->lTimeStart = GetTime(pInfo);
280280

281281
iSockRet = sendto(pInfo->icmpSock, //socket
282-
(char *)pInfo->SendPacket, //buffer
283-
PACKET_SIZE, //size of buffer
282+
(char *)&pInfo->SendPacket->icmpheader,//buffer
283+
sizeof(ICMP_HEADER) + PACKET_SIZE,//size of buffer
284284
0, //flags
285285
(SOCKADDR *)&pInfo->dest, //destination
286286
sizeof(pInfo->dest)); //address length
@@ -598,7 +598,7 @@ Cleanup(PAPPINFO pInfo)
598598
0,
599599
pInfo->SendPacket);
600600

601-
if (pInfo->SendPacket)
601+
if (pInfo->RecvPacket)
602602
HeapFree(GetProcessHeap(),
603603
0,
604604
pInfo->RecvPacket);

reactos/base/applications/network/tracert/tracert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define TTL_EXCEEDED 11
1414

1515
#define MAX_PING_PACKET_SIZE 1024
16-
#define MAX_PING_DATA_SIZE (MAX_PING_PACKET_SIZE + sizeof(IPv4Header)
16+
#define MAX_PING_DATA_SIZE (MAX_PING_PACKET_SIZE + sizeof(IPv4Header))
1717
#define PACKET_SIZE 32
1818
#define ICMP_MIN_SIZE 8
1919

@@ -53,8 +53,8 @@ typedef struct ICMPHeader
5353
/* ICMP Echo Reply Header, 12 bytes */
5454
typedef struct EchoReplyHeader
5555
{
56-
struct ICMPHeader icmpheader;
5756
struct timeval timestamp;
57+
struct ICMPHeader icmpheader;
5858
} ECHO_REPLY_HEADER, *PECHO_REPLY_HEADER;
5959

6060
/* ICMP Echo Reply Header, 12 bytes */

0 commit comments

Comments
 (0)