[SERVER-38742] Coverity analysis defect 105208: Unintentional integer overflow Created: 21/Dec/18  Updated: 29/Oct/23  Resolved: 28/Dec/18

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: None
Fix Version/s: 4.1.7

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Mathias Stearn
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: Service Arch 2018-12-31
Participants:

 Description   

An integer overflow occurs, with the result converted to a wider integer type

Defect 105208 (STATIC_C)
Checker OVERFLOW_BEFORE_WIDEN (subcategory none)
File: /src/mongo/client/replica_set_monitor.cpp
Function mongo::ReplicaSetMonitor::SetState::SetState(mongo::StringData, const std::set<mongo::HostAndPort, std::less<mongo::HostAndPort>, std::allocator<mongo::HostAndPort>> &, mongo::executor::TaskExecutor *, mongo::MongoURI)
/src/mongo/client/replica_set_monitor.cpp, line: 1022
Potentially overflowing expression "mongo::serverGlobalParams.defaultLocalThresholdMillis * 1000" with type "int" (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "int64_t" (64 bits, signed).

          latencyThresholdMicros(serverGlobalParams.defaultLocalThresholdMillis * 1000),



 Comments   
Comment by Githook User [ 28/Dec/18 ]

Author:

{'username': 'RedBeard0531', 'email': 'mathias@10gen.com', 'name': 'Mathias Stearn'}

Message: SERVER-38742 Compute latencyThresholdMicros in 64-bit space
Branch: master
https://github.com/mongodb/mongo/commit/f87a2866a0757833bd2ae35cce709c76a00600d8

Comment by Andy Schwerin [ 26/Dec/18 ]

redbeard0531 has been working in this part of the code. Perhaps he can mop this up while he's in there.

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