Coverity finding CID 147829 Bad bit shift operation (BAD_SHIFT)

I'm fairly certian this is a false positive. Checking GF2NT::MultiplicativeInverse under code coverage shows its exercised 555,735 times. We will clear it anayway to squash the finding
For those not aware, on Linux and Unix, you can issue 'make coverage' and get code coverage statistics
This commit is contained in:
Jeffrey Walton 2016-09-27 20:20:54 -04:00
parent c3e45b2e51
commit 8d227675a9
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

View File

@ -717,8 +717,11 @@ const GF2NT::Element& GF2NT::MultiplicativeInverse(const Element &a) const
for (unsigned int j=0; j<WORD_BITS-t1; j++) for (unsigned int j=0; j<WORD_BITS-t1; j++)
{ {
// Coverity finding on shift amount of 'word x << (t1+j)'. // Coverity finding on shift amount of 'word x << (t1+j)'.
// temp ^= ((temp >> j) & 1) << (t1 + j);
CRYPTOPP_ASSERT(t1+j < WORD_BITS); CRYPTOPP_ASSERT(t1+j < WORD_BITS);
temp ^= ((temp >> j) & 1) << (t1 + j); const unsigned int shift = t1 + j;
temp ^= ((shift >= WORD_BITS) ? 0 : ((temp >> j) & 1) << shift);
} }
} }
else else