Skip to content

Commit a611e76

Browse files
committed
C++: Respond to review comments.
1 parent 238c483 commit a611e76

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ predicate boundedBitwiseAnd(Expr e, Expr andExpr, Expr operand1, Expr operand2)
5959
}
6060

6161
/**
62-
* Holds if `e` is an operand of an operation that greatly reduces the range of possible values.
62+
* Holds if `e` is an arithmetic expression that cannot overflow, or if `e` is an operand of an
63+
* operation that may greatly reduces the range of possible values.
6364
*/
6465
predicate bounded(Expr e) {
6566
(
6667
e instanceof UnaryArithmeticOperation or
67-
e instanceof BinaryArithmeticOperation
68+
e instanceof BinaryArithmeticOperation or
69+
e instanceof AssignArithmeticOperation
6870
) and
6971
not convertedExprMightOverflow(e)
7072
or
@@ -90,7 +92,7 @@ predicate bounded(Expr e) {
9092
boundedBitwiseAnd(e, andExpr, andExpr.getAnOperand(), andExpr.getAnOperand())
9193
)
9294
or
93-
// Optimitically assume that a division always yields a much smaller value.
95+
// Optimitically assume that a division or right shift always yields a much smaller value.
9496
boundedDiv(e, any(DivExpr div).getLeftOperand())
9597
or
9698
boundedDiv(e, any(AssignDivExpr div).getLValue())

0 commit comments

Comments
 (0)