Skip to content

Commit

Permalink
Fix buffer end location (#447)
Browse files Browse the repository at this point in the history
Fix payload buffer to end at actual payload end. UDP header length includes the 8 bytes of the header so we do not want the +8 at the end of the buffer.

Signed-off-by: noiz <noiz@users.noreply.github.com>

Co-authored-by: Pablo Mazzini <pmazzini@gmail.com>
  • Loading branch information
noiz and pmazzini authored Oct 25, 2021
1 parent 63954f9 commit b259fbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dhcpv4/client4/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (c *Client) SendReceive(sendFd, recvFd int, packet *dhcpv4.DHCPv4, messageT
}
// UDP checksum is not checked
pLen := int(binary.BigEndian.Uint16(udph[4:6]))
payload := buf[iph.Len+8 : iph.Len+8+pLen]
payload := buf[iph.Len+8 : iph.Len+pLen]

response, innerErr = dhcpv4.FromBytes(payload)
if innerErr != nil {
Expand Down

0 comments on commit b259fbf

Please sign in to comment.