From 6400dfc9e84eb13dfafda8d05967937b2c843736 Mon Sep 17 00:00:00 2001 From: KonnovKM Date: Thu, 6 Jul 2023 10:30:19 +0300 Subject: header size check Signed-off-by: KonnovKM --- dhcpv4/nclient4/conn_unix.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dhcpv4/nclient4/conn_unix.go b/dhcpv4/nclient4/conn_unix.go index 7f79f50..67ac94c 100644 --- a/dhcpv4/nclient4/conn_unix.go +++ b/dhcpv4/nclient4/conn_unix.go @@ -105,14 +105,15 @@ func (upc *BroadcastRawUDPConn) ReadFrom(b []byte) (int, net.Addr, error) { } ipHdr := ipv4(buf.Data()) + headerLength := ipHdr.headerLength() - if !buf.Has(int(ipHdr.headerLength())) { + if !buf.Has(int(headerLength)) { continue } - ipHdr = ipv4(buf.Consume(int(ipHdr.headerLength()))) + ipHdr = ipv4(buf.Consume(int(headerLength))) - if ipHdr.transportProtocol() != udpProtocolNumber { + if headerLength <= protocol || ipHdr.transportProtocol() != udpProtocolNumber { continue } -- cgit v1.2.3