[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:
whd
2021-05-31 21:47:12 -07:00
committed by GitHub
parent fa8ec6ded0
commit f0f536dab3
+2 -4
View File
@@ -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)