Skip to content

Commit 8fef101

Browse files
committed
C++: Fix missing result and accept test changes.
1 parent 8014bdc commit 8fef101

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

cpp/ql/src/Security/CWE/CWE-190/ArithmeticTainted.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Configuration extends TaintTrackingConfiguration {
3535
op.getAnOperand() = e
3636
|
3737
op instanceof UnaryArithmeticOperation or
38-
op instanceof BinaryArithmeticOperation
38+
op instanceof BinaryArithmeticOperation or
39+
op instanceof AssignArithmeticOperation
3940
)
4041
}
4142

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ edges
88
| test2.cpp:36:9:36:14 | buffer | test2.cpp:39:9:39:11 | num |
99
| test2.cpp:36:9:36:14 | buffer | test2.cpp:39:9:39:11 | num |
1010
| test2.cpp:36:9:36:14 | buffer | test2.cpp:39:9:39:11 | num |
11+
| test2.cpp:36:9:36:14 | buffer | test2.cpp:40:3:40:5 | num |
12+
| test2.cpp:36:9:36:14 | buffer | test2.cpp:40:3:40:5 | num |
13+
| test2.cpp:36:9:36:14 | buffer | test2.cpp:40:3:40:5 | num |
14+
| test2.cpp:36:9:36:14 | buffer | test2.cpp:40:3:40:5 | num |
1115
| test2.cpp:36:9:36:14 | fgets output argument | test2.cpp:39:9:39:11 | num |
1216
| test2.cpp:36:9:36:14 | fgets output argument | test2.cpp:39:9:39:11 | num |
17+
| test2.cpp:36:9:36:14 | fgets output argument | test2.cpp:40:3:40:5 | num |
18+
| test2.cpp:36:9:36:14 | fgets output argument | test2.cpp:40:3:40:5 | num |
1319
| test5.cpp:5:5:5:17 | getTaintedInt indirection | test5.cpp:17:6:17:18 | call to getTaintedInt |
1420
| test5.cpp:5:5:5:17 | getTaintedInt indirection | test5.cpp:17:6:17:18 | call to getTaintedInt |
1521
| test5.cpp:5:5:5:17 | getTaintedInt indirection | test5.cpp:18:6:18:18 | call to getTaintedInt |
@@ -43,6 +49,8 @@ nodes
4349
| test2.cpp:36:9:36:14 | fgets output argument | semmle.label | fgets output argument |
4450
| test2.cpp:39:9:39:11 | num | semmle.label | num |
4551
| test2.cpp:39:9:39:11 | num | semmle.label | num |
52+
| test2.cpp:40:3:40:5 | num | semmle.label | num |
53+
| test2.cpp:40:3:40:5 | num | semmle.label | num |
4654
| test5.cpp:5:5:5:17 | getTaintedInt indirection | semmle.label | getTaintedInt indirection |
4755
| test5.cpp:9:7:9:9 | buf | semmle.label | buf |
4856
| test5.cpp:9:7:9:9 | buf | semmle.label | buf |
@@ -68,6 +76,7 @@ nodes
6876
| test2.cpp:14:11:14:11 | v | test2.cpp:25:22:25:23 | & ... | test2.cpp:14:11:14:11 | v | $@ flows to an operand of an arithmetic expression, potentially causing an overflow. | test2.cpp:25:22:25:23 | & ... | User-provided value |
6977
| test2.cpp:14:11:14:11 | v | test2.cpp:25:22:25:23 | & ... | test2.cpp:14:11:14:11 | v | $@ flows to an operand of an arithmetic expression, potentially causing an underflow. | test2.cpp:25:22:25:23 | & ... | User-provided value |
7078
| test2.cpp:39:9:39:11 | num | test2.cpp:36:9:36:14 | buffer | test2.cpp:39:9:39:11 | num | $@ flows to an operand of an arithmetic expression, potentially causing an overflow. | test2.cpp:36:9:36:14 | buffer | User-provided value |
79+
| test2.cpp:40:3:40:5 | num | test2.cpp:36:9:36:14 | buffer | test2.cpp:40:3:40:5 | num | $@ flows to an operand of an arithmetic expression, potentially causing an overflow. | test2.cpp:36:9:36:14 | buffer | User-provided value |
7180
| test5.cpp:17:6:17:18 | call to getTaintedInt | test5.cpp:9:7:9:9 | buf | test5.cpp:17:6:17:18 | call to getTaintedInt | $@ flows to an operand of an arithmetic expression, potentially causing an overflow. | test5.cpp:9:7:9:9 | buf | User-provided value |
7281
| test5.cpp:19:6:19:6 | y | test5.cpp:9:7:9:9 | buf | test5.cpp:19:6:19:6 | y | $@ flows to an operand of an arithmetic expression, potentially causing an overflow. | test5.cpp:9:7:9:9 | buf | User-provided value |
7382
| test5.cpp:19:6:19:6 | y | test5.cpp:9:7:9:9 | buf | test5.cpp:19:6:19:6 | y | $@ flows to an operand of an arithmetic expression, potentially causing an underflow. | test5.cpp:9:7:9:9 | buf | User-provided value |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ void test3()
3737

3838
int num = atoi(buffer);
3939
num = num + 1000; // BAD
40-
num += 1000; // BAD [NOT DETECTED]
40+
num += 1000; // BAD
4141
}

0 commit comments

Comments
 (0)