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:
Owen Mansel-Chan
2021-11-01 06:23:56 +00:00
parent 2cc0c80188
commit 5027d3fa44

View File

@@ -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()
}
}