mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 00:49:53 +00:00
[udp] fix potential infinite loop in Udp::GetEphemeralPort (#6697)
The current implementation will go into an infinite loop when mEphemeralPort == Tmf::kUdpPort, since rval is never updated in the loop. This commit fixes this issue.
This commit is contained in:
@@ -407,8 +407,6 @@ exit:
|
||||
|
||||
uint16_t Udp::GetEphemeralPort(void)
|
||||
{
|
||||
uint16_t rval = mEphemeralPort;
|
||||
|
||||
do
|
||||
{
|
||||
if (mEphemeralPort < kDynamicPortMax)
|
||||
@@ -419,9 +417,9 @@ uint16_t Udp::GetEphemeralPort(void)
|
||||
{
|
||||
mEphemeralPort = kDynamicPortMin;
|
||||
}
|
||||
} while (rval == Tmf::kUdpPort);
|
||||
} while (mEphemeralPort == Tmf::kUdpPort);
|
||||
|
||||
return rval;
|
||||
return mEphemeralPort;
|
||||
}
|
||||
|
||||
Message *Udp::NewMessage(uint16_t aReserved, const Message::Settings &aSettings)
|
||||
|
||||
Reference in New Issue
Block a user