From: Cameron Gutman Date: Tue, 20 Oct 2009 06:07:34 +0000 (+0000) Subject: - Fix a typo in checksum calculation for datagrams with an odd number of octets X-Git-Tag: ReactOS-0.3.11~377 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=13c453792d0e302c187926c6fc23acb6f45d595e - Fix a typo in checksum calculation for datagrams with an odd number of octets - Allow packets with no checksum - Remove debug prints that got left behind svn path=/trunk/; revision=43638 --- diff --git a/reactos/lib/drivers/ip/network/checksum.c b/reactos/lib/drivers/ip/network/checksum.c index 18f81d934b6..1cc96637b69 100644 --- a/reactos/lib/drivers/ip/network/checksum.c +++ b/reactos/lib/drivers/ip/network/checksum.c @@ -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; } diff --git a/reactos/lib/drivers/ip/transport/udp/udp.c b/reactos/lib/drivers/ip/transport/udp/udp.c index b6ad0d0db38..2f499c97b66 100644 --- a/reactos/lib/drivers/ip/transport/udp/udp.c +++ b/reactos/lib/drivers/ip/transport/udp/udp.c @@ -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;