Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out of bounds read #507

Merged
merged 7 commits into from
Jul 31, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions dhcpv4/nclient4/conn_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,18 @@
}

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 {
continue
if headerLength > protocol {
if ipHdr.transportProtocol() != udpProtocolNumber {
continue

Check warning on line 118 in dhcpv4/nclient4/conn_unix.go

View check run for this annotation

Codecov / codecov/patch

dhcpv4/nclient4/conn_unix.go#L118

Added line #L118 was not covered by tests
}
}

if !buf.Has(udpHdrLen) {
pmazzini marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading