summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKonnovKM <boneyandoom@gmail.com>2023-07-06 10:30:19 +0300
committerKonnovKM <boneyandoom@gmail.com>2023-07-18 10:23:06 +0300
commit6400dfc9e84eb13dfafda8d05967937b2c843736 (patch)
tree5432e1f9ce48626018fc8d477a859143101690ae
parentb20c9ba983dfec6371555e7baa343aabd388b22c (diff)
header size check
Signed-off-by: KonnovKM <boneyandoom@gmail.com>
-rw-r--r--dhcpv4/nclient4/conn_unix.go7
1 files 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
}