diff options
Diffstat (limited to 'dhcpv4/nclient4/conn_unix.go')
-rw-r--r-- | dhcpv4/nclient4/conn_unix.go | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/dhcpv4/nclient4/conn_unix.go b/dhcpv4/nclient4/conn_unix.go index 239d007..1495dc2 100644 --- a/dhcpv4/nclient4/conn_unix.go +++ b/dhcpv4/nclient4/conn_unix.go @@ -99,24 +99,16 @@ func (upc *BroadcastRawUDPConn) ReadFrom(b []byte) (int, net.Addr, error) { pkt = pkt[:n] buf := uio.NewBigEndianBuffer(pkt) - // To read the header length, access data directly. - if !buf.Has(ipv4MinimumSize) { - continue - } - ipHdr := ipv4(buf.Data()) - headerLength := ipHdr.headerLength() - if !buf.Has(int(headerLength)) { + if !ipHdr.isValid(n) { continue } - ipHdr = ipv4(buf.Consume(int(headerLength))) + ipHdr = ipv4(buf.Consume(int(ipHdr.headerLength()))) - if headerLength > protocol { - if ipHdr.transportProtocol() != udpProtocolNumber { - continue - } + if ipHdr.transportProtocol() != udpProtocolNumber { + continue } if !buf.Has(udpHdrLen) { |