From 41bcf762bf805fc51ce2974a755dff2c315802e6 Mon Sep 17 00:00:00 2001 From: Fei Chong <13114351+ZgblKylin@users.noreply.github.com> Date: Thu, 2 Nov 2023 15:38:58 +0800 Subject: [PATCH] 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: fei.chong@calmcar.com Signed-off-by: Fei Chong <13114351+ZgblKylin@users.noreply.github.com> --- src/cpp/utils/IPFinder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/utils/IPFinder.cpp b/src/cpp/utils/IPFinder.cpp index 9f9ff89c0d2..daf61d24a48 100644 --- a/src/cpp/utils/IPFinder.cpp +++ b/src/cpp/utils/IPFinder.cpp @@ -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()) {