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 Sep 22, 2021
1 parent f7c5127 commit 0ade2d5
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 0ade2d5

Please sign in to comment.