Skip to content

Commit

Permalink
packet: fix crasher found by go-fuzz due to misleading IP address len…
Browse files Browse the repository at this point in the history
…gths
  • Loading branch information
mdlayher committed Jul 30, 2015
1 parent 985d9a7 commit f237799
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ func (p *Packet) MarshalBinary() ([]byte, error) {
// 1 byte : protocol length
// 2 bytes: operation
// N bytes: source hardware address
// 4 bytes: source protocol address
// N bytes: source protocol address
// N bytes: target hardware address
// 4 bytes: target protocol address
b := make([]byte, 2+2+1+1+2+4+4+(p.HardwareAddrLength*2))
// N bytes: target protocol address

// Though an IPv4 address should always 4 bytes, go-fuzz
// very quickly created several crasher scenarios which
// indicated that these values can lie.
b := make([]byte, 2+2+1+1+2+(p.IPLength*2)+(p.HardwareAddrLength*2))

// Marshal fixed length data

Expand Down

0 comments on commit f237799

Please sign in to comment.