Skip to content

Commit 5b9e572

Browse files
committed
INT32-C: Report issues in guards
Signed integer overflow and underflow is undefined behavior, and so, unlike unsigned wraparound, it's not valid to do so even in a guard condition.
1 parent 6dd30df commit 5b9e572

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

c/cert/src/rules/INT32-C/SignedIntegerOverflow.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ from InterestingBinaryOverflowingExpr bop
2222
where
2323
not isExcluded(bop, IntegerOverflowPackage::signedIntegerOverflowQuery()) and
2424
bop.getType().getUnderlyingType().(IntegralType).isSigned() and
25-
// Not within a guard condition
26-
not exists(GuardCondition gc | gc.getAChild*() = bop) and
2725
// Not checked before the operation
2826
not bop.hasValidPreCheck() and
2927
// Not guarded by a check, where the check is not an invalid overflow check

c/cert/test/rules/INT32-C/SignedIntegerOverflow.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| test.c:6:3:6:9 | ... + ... | Binary expression ...+... of type int may overflow or underflow. |
2+
| test.c:20:7:20:13 | ... + ... | Binary expression ...+... of type int may overflow or underflow. |
23
| test.c:23:5:23:11 | ... + ... | Binary expression ...+... of type int may overflow or underflow. |
34
| test.c:28:19:28:25 | ... + ... | Binary expression ...+... of type int may overflow or underflow. |
45
| test.c:36:3:36:9 | ... - ... | Binary expression ...-... of type int may overflow or underflow. |

0 commit comments

Comments
 (0)