Skip to content

Commit

Permalink
AddressSanitizer: SEGV on unknown address in src/platform/Linux/Platf…
Browse files Browse the repository at this point in the history
…ormManagerImpl.cpp (#14701)
  • Loading branch information
vivien-apple authored Feb 3, 2022
1 parent 4676ea2 commit c91cea8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <arpa/inet.h>
#include <dirent.h>
#include <errno.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <net/if.h>
Expand Down Expand Up @@ -170,13 +171,19 @@ void PlatformManagerImpl::WiFIIPChangeListener()
if (routeInfo->rta_type == IFA_LOCAL)
{
char name[IFNAMSIZ];
ChipDeviceEvent event;
if_indextoname(addressMessage->ifa_index, name);
if (if_indextoname(addressMessage->ifa_index, name) == NULL)
{
ChipLogError(DeviceLayer, "Error %d when getting the interface name at index: %d", errno,
addressMessage->ifa_index);
continue;
}

if (strcmp(name, ConnectivityManagerImpl::GetWiFiIfName()) != 0)
{
continue;
}

ChipDeviceEvent event;
event.Type = DeviceEventType::kInternetConnectivityChange;
event.InternetConnectivityChange.IPv4 = kConnectivity_Established;
event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange;
Expand Down

0 comments on commit c91cea8

Please sign in to comment.