Skip to content

Commit

Permalink
Fix: mac address overflow on windows
Browse files Browse the repository at this point in the history
PIP_ADAPTER_ADDRESSES->PhysicalAddressLength will get max up to 8 bytes, but we have only 6 bytes for mac address.
In some case, GetAdaptersAddresses() will report address with PhysicalAddressLength=8, e.g. "Microsoft Teredo Tunneling Adapter", which will cause crash at DomainParticipantFactory::create_participant()

Signed-off-by: [email protected] <[email protected]>
Signed-off-by: Fei Chong <[email protected]>
  • Loading branch information
ZgblKylin committed Nov 2, 2023
1 parent 16e7d90 commit 41bcf76
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cpp/utils/IPFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool IPFinder::getAllMACAddress(
if (aa->OperStatus == 1) //is ENABLED
{
info_MAC mac;
memcpy(mac.address, aa->PhysicalAddress, aa->PhysicalAddressLength);
memcpy(mac.address, aa->PhysicalAddress, std::min(6UL, aa->PhysicalAddressLength));

if (std::find(macs->begin(), macs->end(), mac) == macs->end())
{
Expand Down

0 comments on commit 41bcf76

Please sign in to comment.