[SERVER-50203] Coverity analysis defect 116119: Argument cannot be negative Created: 08/Aug/20  Updated: 29/Oct/23  Resolved: 11/Jan/21

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Dan Larkin-York
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-01-11, Execution Team 2021-01-25
Participants:

 Description   

Argument cannot be negative

The negative argument will be interpreted as a very large unsigned value. Negative value used as argument to a function expecting a positive value (for example, size of buffer or allocation)
/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h:2271: REVERSE_NEGATIVE 116119 Passing "context->size() - 2UL" to a parameter that cannot be negative. [Note: The source code implementation of the function has been overridden by a builtin model.]
/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h:2290: REVERSE_NEGATIVE 116119 Assigning: "prevIdx" = "context->size() - 2UL"; now neither can be negative.
/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h:2292: REVERSE_NEGATIVE 116119 You might be using variable "prevIdx" before verifying that it is >= 0.



 Comments   
Comment by Githook User [ 11/Jan/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-50203 Prevent passing unsigned argument a negative value in ephemeral_for_test::RadixStore
Branch: master
https://github.com/mongodb/mongo/commit/479de17951ef3e0d7f74f6e087b267b22c765bff

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