From 6378dd7cf49e34a24b8b85b21eea30f4d5458409 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Tue, 26 Dec 2006 19:12:35 +0000 Subject: [PATCH] Fixed endian errors in UDP source and destination port handling. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19633 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/loader/net/UDP.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/system/boot/loader/net/UDP.cpp b/src/system/boot/loader/net/UDP.cpp index c2a02e1168..e5eb1bea45 100644 --- a/src/system/boot/loader/net/UDP.cpp +++ b/src/system/boot/loader/net/UDP.cpp @@ -288,9 +288,12 @@ UDPService::HandleIPPacket(IPService *ipService, ip_addr_t sourceIP, if (!data || size < sizeof(udp_header)) return; - // check the header const udp_header *header = (const udp_header*)data; + uint16 source = ntohs(header->source); + uint16 destination = ntohs(header->destination); uint16 length = ntohs(header->length); + + // check the header if (length < sizeof(udp_header) || length > size || (header->checksum != 0 // 0 => checksum disabled && _ChecksumData(data, length, sourceIP, destinationIP) != 0)) { @@ -300,7 +303,7 @@ UDPService::HandleIPPacket(IPService *ipService, ip_addr_t sourceIP, } // find the target socket - UDPSocket *socket = _FindSocket(destinationIP, header->destination); + UDPSocket *socket = _FindSocket(destinationIP, destination); if (!socket) return; @@ -309,8 +312,8 @@ UDPService::HandleIPPacket(IPService *ipService, ip_addr_t sourceIP, if (!packet) return; status_t error = packet->SetTo((uint8*)data + sizeof(udp_header), - length - sizeof(udp_header), sourceIP, header->source, destinationIP, - header->destination); + length - sizeof(udp_header), sourceIP, source, destinationIP, + destination); if (error == B_OK) socket->PushPacket(packet); else