Skip to content

Commit 91893ae

Browse files
committed
CPP: Fix crement operations on pointers.
1 parent a615422 commit 91893ae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp/ql/src/semmle/code/cpp/security/Overflow.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ predicate missingGuardAgainstOverflow(Operation e, VariableAccess use) {
6363
exists(LocalScopeVariable v | use.getTarget() = v |
6464
// overflow possible if large
6565
(e instanceof AddExpr and not guardedLesser(e, varUse(v))) or
66-
(e instanceof IncrementOperation and not guardedLesser(e, varUse(v))) or
66+
(e instanceof IncrementOperation and not guardedLesser(e, varUse(v)) and v.getType().getUnspecifiedType() instanceof IntegralType) or
6767
// overflow possible if large or small
6868
(e instanceof MulExpr and
6969
not (guardedLesser(e, varUse(v)) and guardedGreater(e, varUse(v))))
@@ -77,7 +77,7 @@ predicate missingGuardAgainstUnderflow(Operation e, VariableAccess use) {
7777
// underflow possible if use is left operand and small
7878
(use = e.(SubExpr).getLeftOperand() and not guardedGreater(e, varUse(v))) or
7979
// underflow possible if small
80-
(e instanceof DecrementOperation and not guardedGreater(e, varUse(v))) or
80+
(e instanceof DecrementOperation and not guardedGreater(e, varUse(v)) and v.getType().getUnspecifiedType() instanceof IntegralType) or
8181
// underflow possible if large or small
8282
(e instanceof MulExpr and
8383
not (guardedLesser(e, varUse(v)) and guardedGreater(e, varUse(v))))

0 commit comments

Comments
 (0)