Skip to content

Commit

Permalink
[linux] Fix possible infinite loop (#9883)
Browse files Browse the repository at this point in the history
The code for getting Wi-Fi IP address may enter an infinite
loop when the expected wlan interface does not exist.
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Oct 1, 2021
1 parent 48e43b7 commit 1158072
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void PlatformManagerImpl::WiFIIPChangeListener()
struct rtattr * routeInfo = IFA_RTA(addressMessage);
size_t rtl = IFA_PAYLOAD(header);

while (rtl && RTA_OK(routeInfo, rtl))
for (; rtl && RTA_OK(routeInfo, rtl); routeInfo = RTA_NEXT(routeInfo, rtl))
{
if (routeInfo->rta_type == IFA_LOCAL)
{
Expand All @@ -115,7 +115,6 @@ void PlatformManagerImpl::WiFIIPChangeListener()
ChipLogDetail(DeviceLayer, "Failed to report IP address: %" CHIP_ERROR_FORMAT, status.Format());
}
}
routeInfo = RTA_NEXT(routeInfo, rtl);
}
}
}
Expand Down

0 comments on commit 1158072

Please sign in to comment.