mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 03:07:47 +00:00
[mle] avoid "1U << 32" when calculating attach start delay backoff (#3410)
This change avoids the use of (potentially) undefined "1U << 32" when calculating the backoff delay for attach re-attempt in MLE. Credit for this bug goes to Coverity.
This commit is contained in:
committed by
Jonathan Hui
parent
cdf0b7785d
commit
3a6c5de3da
@@ -669,7 +669,7 @@ uint32_t Mle::GetAttachStartDelay(void) const
|
||||
uint16_t counter = mAttachCounter - 1;
|
||||
const uint32_t ratio = kAttachBackoffMaxInterval / kAttachBackoffMinInterval;
|
||||
|
||||
if ((counter <= sizeof(ratio) * CHAR_BIT) && ((1U << counter) <= ratio))
|
||||
if ((counter < sizeof(ratio) * CHAR_BIT) && ((1UL << counter) <= ratio))
|
||||
{
|
||||
delay = kAttachBackoffMinInterval;
|
||||
delay <<= counter;
|
||||
|
||||
Reference in New Issue
Block a user