[SERVER-23897] Coverity analysis defect 98887: Division or modulo by zero Created: 25/Apr/16  Updated: 05/Apr/17  Resolved: 05/May/16

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: James Wahlin
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-23896 Don't allow mod by 0 in ExpressionMod... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 14 (05/13/16)
Participants:

 Description   

Division or modulo by zero results in undefined behavior.

Defect 98887 (STATIC_C)
Checker DIVIDE_BY_ZERO (subcategory none)
File: /src/mongo/db/pipeline/expression.cpp
Function mongo::ExpressionMod::evaluateInternal(mongo::Variables *) const
/src/mongo/db/pipeline/expression.cpp, line: 1990
Assigning: "rightLong" = "rhs.coerceToLong()". The value of "rightLong" is now 0.

                long long rightLong = rhs.coerceToLong();

/src/mongo/db/pipeline/expression.cpp, line: 1991
In expression "left % rightLong", modulo by expression "rightLong" which may be zero has undefined behavior.

                return Value(left % rightLong);



 Comments   
Comment by James Wahlin [ 05/May/16 ]

This defect will be handled under SERVER-23896.

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