defense in depth: verify hex.DecodeString length

related to #49
This commit is contained in:
Michael Stapelberg 2020-05-27 09:50:04 +02:00
parent ead58ad72c
commit 4a5f55a5de

View File

@ -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