Skip to content

Commit

Permalink
fix: #518 limit length of hardware address on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
landerverhacklansweeper authored and kayoub5 committed Sep 19, 2024
1 parent 27d063a commit c086df6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SharpPcap/LibPcap/Sockaddr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ internal Sockaddr(IntPtr sockaddrPtr)

var saddr_ll = Marshal.PtrToStructure<sockaddr_ll>(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
}
Expand Down

0 comments on commit c086df6

Please sign in to comment.