C++: Prevent flow out of pointer-difference expressions.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-05-14 13:49:48 +02:00
parent c1d41b3169
commit 2d0a56128d
3 changed files with 8 additions and 50 deletions

View File

@@ -42,6 +42,12 @@ class TaintedAllocationSizeConfiguration extends TaintTrackingConfiguration {
e instanceof AssignArithmeticOperation
) and
not convertedExprMightOverflow(e)
or
// Subtracting two pointers is either well-defined (and the result will likely be small), or
// terribly undefined and dangerous. Here, we assume that the programmer has ensured that the
// result is well-defined (i.e., the two pointers point to the same object), and thus the result
// will likely be small.
e = any(PointerDiffExpr diff).getAnOperand()
}
}