mirror of
https://github.com/github/codeql.git
synced 2026-01-30 23:02:56 +01:00
Avoid using getIntValue()
Because it does not have a result if the value is too large to fit in a 32-bit signed integer type
This commit is contained in:
@@ -143,7 +143,10 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
|
||||
|
||||
/** An upper bound check that compares a variable to a constant value. */
|
||||
class UpperBoundCheckGuard extends DataFlow::BarrierGuard, DataFlow::RelationalComparisonNode {
|
||||
UpperBoundCheckGuard() { count(expr.getAnOperand().getIntValue()) = 1 }
|
||||
UpperBoundCheckGuard() {
|
||||
count(expr.getAnOperand().getExactValue()) = 1 and
|
||||
expr.getAnOperand().getType().getUnderlyingType() instanceof IntegerType
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the constant value which this upper bound check ensures the
|
||||
@@ -159,7 +162,7 @@ class UpperBoundCheckGuard extends DataFlow::BarrierGuard, DataFlow::RelationalC
|
||||
|
||||
override predicate checks(Expr e, boolean branch) {
|
||||
this.leq(branch, DataFlow::exprNode(e), _, _) and
|
||||
not exists(e.getIntValue())
|
||||
not e.isConst()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user