Skip to content

Commit

Permalink
defense in depth: verify hex.DecodeString length
Browse files Browse the repository at this point in the history
related to #49
  • Loading branch information
stapelberg committed May 27, 2020
1 parent ead58ad commit 4a5f55a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/dhcp4d/dhcp4d.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ func (h *Handler) leasePeriodForDevice(hwAddr string) time.Duration {
if err != nil {
return h.LeasePeriod
}
if len(hwAddrPrefix) != 6 {
// Invalid MAC address
return h.LeasePeriod
}
hwAddrPrefix = hwAddrPrefix[:3]
i := sort.Search(len(nintendoMacPrefixes), func(i int) bool {
return bytes.Compare(nintendoMacPrefixes[i][:], hwAddrPrefix) >= 0
Expand Down

0 comments on commit 4a5f55a

Please sign in to comment.