Skip to content

Commit

Permalink
Fix: mac address overflow on windows (#3983) (#4019)
Browse files Browse the repository at this point in the history
* Fix: mac address overflow on windows

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

* Fix build error due to windows `min` macro

Signed-off-by: Miguel Company <[email protected]>

---------

Signed-off-by: [email protected] <[email protected]>
Signed-off-by: Fei Chong <[email protected]>
Signed-off-by: Miguel Company <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
(cherry picked from commit 2601e95)

Co-authored-by: Fei Chong <[email protected]>
  • Loading branch information
mergify[bot] and ZgblKylin authored Dec 11, 2023
1 parent 9c8b88b commit b70bdfc
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 b70bdfc

Please sign in to comment.