diff --git a/SharpPcap/LibPcap/Sockaddr.cs b/SharpPcap/LibPcap/Sockaddr.cs index 16ddd558..3f603cd6 100755 --- a/SharpPcap/LibPcap/Sockaddr.cs +++ b/SharpPcap/LibPcap/Sockaddr.cs @@ -97,7 +97,8 @@ internal Sockaddr(IntPtr sockaddrPtr) var saddr_ll = Marshal.PtrToStructure(sockaddrPtr); - var hwAddrBytes = new byte[saddr_ll.sll_halen]; + var hwAddrBytesLength = Math.Min(saddr_ll.sll_halen,(byte)8); // allow max length of 8 bytes (for exotic hardware that doesn't follow the linux standard) + var hwAddrBytes = new byte[hwAddrBytesLength]; Buffer.BlockCopy(saddr_ll.sll_addr, 0, hwAddrBytes, 0, hwAddrBytes.Length); hardwareAddress = new PhysicalAddress(hwAddrBytes); // copy into the PhysicalAddress class }