From 3a6c5de3dab9bb41100513d8d51ccbaa64dca1e5 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 2 Jan 2019 09:02:40 -0800 Subject: [PATCH] [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. --- src/core/thread/mle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 729c7b4ad..00164880d 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -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;