[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:
Abtin Keshavarzian
2019-01-02 09:02:40 -08:00
committed by Jonathan Hui
parent cdf0b7785d
commit 3a6c5de3da
+1 -1
View File
@@ -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;