[SERVER-60170] Coverity analysis defect 120798: Unintended sign extension Created: 23/Sep/21  Updated: 29/Oct/23  Resolved: 06/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Josef Ahmad
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: Execution Team 2021-10-18
Participants:

 Description   

Unintended sign extension

The sign-extended value may be interpreted as a very large number. Value may be sign extended unintentionally
/src/mongo/db/storage/key_string.cpp:2553: SIGN_EXTENSION 120798 Suspicious implicit sign extension: "sizes[sizeByteId]" with type "uint8_t" (8 bits, unsigned) is promoted in "sizes[sizeByteId] << (numSegments - sizeByteId - 1UL) * 7UL" to type "int" (32 bits, signed), then sign-extended to type "unsigned long" (64 bits, unsigned). If "sizes[sizeByteId] << (numSegments - sizeByteId - 1UL) * 7UL" is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.



 Comments   
Comment by Githook User [ 06/Oct/21 ]

Author:

{'name': 'Josef Ahmad', 'email': 'josef.ahmad@mongodb.com', 'username': 'josefahmad'}

Message: SERVER-60170 Keystring: fix theoretical issue decoding RID size
Branch: master
https://github.com/mongodb/mongo/commit/a76e142d4a3b18cba31183efd2b3d306b909b2ce

Generated at Thu Feb 08 05:49:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.