Skip to content

Commit 948f1d8

Browse files
committed
C++: Add testcase with INTMAX_MIN.
1 parent 3e21f47 commit 948f1d8

File tree

1 file changed

+10
-0
lines changed
  • cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/tainted

1 file changed

+10
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/tainted/test5.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,14 @@ void useTaintedIntWithGuard() {
2929
if(imaxabs(tainted) <= 100) {
3030
int product = tainted * tainted; // GOOD: can't underflow/overflow
3131
}
32+
}
33+
34+
#define INTMAX_MIN (-0x7fffffffffffffff - 1)
35+
36+
void useTaintedIntWithGuardIntMaxMin() {
37+
intmax_t tainted = getTaintedInt();
38+
39+
if(imaxabs(tainted) <= INTMAX_MIN) {
40+
int product = tainted * tainted; // BAD: imaxabs(INTMAX_MIN) == INTMAX_MIN [NOT DETECTED]
41+
}
3242
}

0 commit comments

Comments
 (0)