[SERVER-71294] Coverity analysis defect 134121: Bad bit shift operation Created: 13/Nov/22  Updated: 29/Oct/23  Resolved: 28/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Mark Benvenuto
Resolution: Fixed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Security 2022-11-28, Security 2022-12-12
Participants:

 Description   

Bad bit shift operation

The operation may have an undefined behavior or yield an unexpected result. A bit shift operation has a shift amount which is too large or has a negative value.
/src/mongo/crypto/fle_crypto.cpp:3707: BAD_SHIFT 134121 Function call "bits_range_dec.toIntExact(mongo::Decimal128::kRoundTowardPositive)" may return -2147483648.
/src/mongo/crypto/fle_crypto.cpp:3707: BAD_SHIFT 134121 Assigning: "bits_range" = "bits_range_dec.toIntExact(mongo::Decimal128::kRoundTowardPositive)". The value of "bits_range" is now -2147483648.
/src/mongo/crypto/fle_crypto.cpp:3755: BAD_SHIFT 134121 In expression "1ULL << bits_range", shifting by a negative amount has undefined behavior. The shift amount, "bits_range", is -2147483648.



 Comments   
Comment by Githook User [ 28/Nov/22 ]

Author:

{'name': 'Mark Benvenuto', 'email': 'mark.benvenuto@mongodb.com', 'username': 'markbenvenuto'}

Message: SERVER-71294 Coverity analysis defect 134121: Bad bit shift operation
Branch: master
https://github.com/mongodb/mongo/commit/2a8e136b7a5b81149c05847a5561c75f34ba50fc

Generated at Thu Feb 08 06:18:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.