From 0c79c68d93d721d37ba088fb50dbf07bb0d447e5 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 6 Apr 2014 19:35:36 +0200 Subject: sd-dhcp-client: eagerly drop too small packets If they are too small to fit the IP+UDP+DHCP headers they can be of no use, so don't waste resources parsing them. This is at the cost of losing some verbosity in the logging. --- src/libsystemd-network/dhcp-packet.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/libsystemd-network/dhcp-packet.c') diff --git a/src/libsystemd-network/dhcp-packet.c b/src/libsystemd-network/dhcp-packet.c index 0549f575ac..102ed096af 100644 --- a/src/libsystemd-network/dhcp-packet.c +++ b/src/libsystemd-network/dhcp-packet.c @@ -113,13 +113,6 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum) { /* IP */ - if (len < DHCP_IP_SIZE) { - log_dhcp_client(client, "ignoring packet: packet (%zu bytes) " - " smaller than IP header (%u bytes)", len, - DHCP_IP_SIZE); - return -EINVAL; - } - if (packet->ip.version != IPVERSION) { log_dhcp_client(client, "ignoring packet: not IPv4"); return -EINVAL; @@ -152,13 +145,6 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum) { return -EINVAL; } - if (len < DHCP_IP_UDP_SIZE) { - log_dhcp_client(client, "ignoring packet: packet (%zu bytes) " - " smaller than IP+UDP header (%u bytes)", len, - DHCP_IP_UDP_SIZE); - return -EINVAL; - } - if (len < hdrlen + be16toh(packet->udp.len)) { log_dhcp_client(client, "ignoring packet: packet (%zu bytes) " "smaller than expected (%zu) by UDP header", len, -- cgit v1.2.3-54-g00ecf