Skip to content

Commit

Permalink
Merge pull request #29 from maxosprojects/fix-phys-addr-len-mismatch
Browse files Browse the repository at this point in the history
fix(phys-addr-length): fix physical address length mismatch
  • Loading branch information
willscott committed Nov 1, 2022
2 parents 6bd210a + b72d8b5 commit c466fa2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion netroute_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,18 @@ func getIface(index uint32) *net.Interface {
return nil
}

physAddrLen := int(ifRow.PhysAddrLen)
if len(ifRow.PhysAddr) < physAddrLen && physAddrLen >= 0 {
physAddrLen = len(ifRow.PhysAddr)
}
physAddr := ifRow.PhysAddr[:physAddrLen]

ifaces, err := net.Interfaces()
if err != nil {
return nil
}
for _, iface := range ifaces {
if bytes.Equal(iface.HardwareAddr, ifRow.PhysAddr[:]) {
if bytes.Equal(iface.HardwareAddr, physAddr) {
return &iface
}
}
Expand Down

0 comments on commit c466fa2

Please sign in to comment.