- Fix a typo in checksum calculation for datagrams with an odd number of octets
authorCameron Gutman <aicommander@gmail.com>
Tue, 20 Oct 2009 06:07:34 +0000 (06:07 +0000)
committerCameron Gutman <aicommander@gmail.com>
Tue, 20 Oct 2009 06:07:34 +0000 (06:07 +0000)
 - Allow packets with no checksum
 - Remove debug prints that got left behind

svn path=/trunk/; revision=43638

reactos/lib/drivers/ip/network/checksum.c
reactos/lib/drivers/ip/transport/udp/udp.c

index 18f81d9..1cc9663 100644 (file)
@@ -69,16 +69,14 @@ UDPv4ChecksumCalculate(
 
   /* Pad the data if needed */
   Pad = (DataLength & 1);
-  if (Pad) {
-      DbgPrint("Odd\n");
+  if (Pad)
       DataLength++;
-  } else DbgPrint("Even\n");
 
   /* Add from the UDP header and data */
   for (i = 0; i < DataLength; i += 2)
   {
        TmpSum = ((PacketBuffer[i] << 8) & 0xFF00) +
-                ((Pad && i == DataLength - 1) ? 0 : (PacketBuffer[i+1] & 0x00FF));
+                ((Pad && i == DataLength - 2) ? 0 : (PacketBuffer[i+1] & 0x00FF));
        Sum += TmpSum;
   }
 
index b6ad0d0..2f499c9 100644 (file)
@@ -267,7 +267,7 @@ VOID UDPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
   i = UDPv4ChecksumCalculate(IPv4Header,
                              (PUCHAR)UDPHeader,
                              WH2N(UDPHeader->Length));
-  if (i != DH2N(0x0000FFFF))
+  if (i != DH2N(0x0000FFFF) && UDPHeader->Checksum != 0)
   {
       TI_DbgPrint(MIN_TRACE, ("Bad checksum on packet received.\n"));
       return;