From a81f2fef56421a82b030160df9c548aa74254477 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 28 May 2021 18:43:52 +0200 Subject: [PATCH] dhcp: convert port check to hard assert. --- src/socket/dhcpv4.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/socket/dhcpv4.rs b/src/socket/dhcpv4.rs index 1f278e6..cc61373 100644 --- a/src/socket/dhcpv4.rs +++ b/src/socket/dhcpv4.rs @@ -161,9 +161,8 @@ impl Dhcpv4Socket { pub(crate) fn process(&mut self, now: Instant, ethernet_addr: EthernetAddress, ip_repr: &Ipv4Repr, repr: &UdpRepr, payload: &[u8]) -> Result<()> { let src_ip = ip_repr.src_addr; - if repr.src_port != DHCP_SERVER_PORT || repr.dst_port != DHCP_CLIENT_PORT { - return Ok(()) - } + // This is enforced in interface.rs. + assert!(repr.src_port == DHCP_SERVER_PORT && repr.dst_port == DHCP_CLIENT_PORT); let dhcp_packet = match DhcpPacket::new_checked(payload) { Ok(dhcp_packet) => dhcp_packet,