Skip to content

Commit a3579f6

Browse files
authored
Merge branch 'main' into typos
2 parents 935b760 + 650d806 commit a3579f6

File tree

24 files changed

+518
-192
lines changed

24 files changed

+518
-192
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,10 @@ private module GetConvertedResultExpression {
10661066
private import semmle.code.cpp.ir.implementation.raw.internal.TranslatedExpr
10671067
private import semmle.code.cpp.ir.implementation.raw.internal.InstructionTag
10681068

1069+
private Operand getAnInitializeDynamicAllocationInstructionAddress() {
1070+
result = any(InitializeDynamicAllocationInstruction init).getAllocationAddressOperand()
1071+
}
1072+
10691073
/**
10701074
* Gets the expression that should be returned as the result expression from `instr`.
10711075
*
@@ -1074,7 +1078,16 @@ private module GetConvertedResultExpression {
10741078
*/
10751079
Expr getConvertedResultExpression(Instruction instr, int n) {
10761080
// Only fully converted instructions have a result for `asConvertedExpr`
1077-
not conversionFlow(unique( | | getAUse(instr)), _, false, false) and
1081+
not conversionFlow(unique(Operand op |
1082+
// The address operand of a `InitializeDynamicAllocationInstruction` is
1083+
// special: we need to handle it during dataflow (since it's
1084+
// effectively a store to an indirection), but it doesn't appear in
1085+
// source syntax, so dataflow node <-> expression conversion shouldn't
1086+
// care about it.
1087+
op = getAUse(instr) and not op = getAnInitializeDynamicAllocationInstructionAddress()
1088+
|
1089+
op
1090+
), _, false, false) and
10781091
result = getConvertedResultExpressionImpl(instr) and
10791092
n = 0
10801093
or

cpp/ql/test/query-tests/Security/CWE/CWE-119/SAMATE/OverrunWriteProductFlow.expected

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,19 @@ edges
4747
| test.cpp:207:17:207:19 | str indirection [string] | test.cpp:207:22:207:27 | string |
4848
| test.cpp:214:24:214:24 | p | test.cpp:216:10:216:10 | p |
4949
| test.cpp:220:27:220:54 | call to malloc | test.cpp:222:15:222:20 | buffer |
50-
| test.cpp:220:43:220:48 | call to malloc | test.cpp:222:15:222:20 | buffer |
5150
| test.cpp:222:15:222:20 | buffer | test.cpp:214:24:214:24 | p |
5251
| test.cpp:228:27:228:54 | call to malloc | test.cpp:232:10:232:15 | buffer |
53-
| test.cpp:228:43:228:48 | call to malloc | test.cpp:232:10:232:15 | buffer |
5452
| test.cpp:235:40:235:45 | buffer | test.cpp:236:5:236:26 | ... = ... |
5553
| test.cpp:236:5:236:26 | ... = ... | test.cpp:236:12:236:17 | p_str indirection [post update] [string] |
5654
| test.cpp:241:20:241:38 | call to malloc | test.cpp:242:22:242:27 | buffer |
57-
| test.cpp:241:27:241:32 | call to malloc | test.cpp:242:22:242:27 | buffer |
5855
| test.cpp:242:16:242:19 | set_string output argument [string] | test.cpp:243:12:243:14 | str indirection [string] |
5956
| test.cpp:242:22:242:27 | buffer | test.cpp:235:40:235:45 | buffer |
6057
| test.cpp:242:22:242:27 | buffer | test.cpp:242:16:242:19 | set_string output argument [string] |
6158
| test.cpp:243:12:243:14 | str indirection [string] | test.cpp:243:12:243:21 | string |
6259
| test.cpp:249:14:249:33 | call to my_alloc | test.cpp:250:12:250:12 | p |
6360
| test.cpp:256:9:256:25 | call to malloc | test.cpp:257:12:257:12 | p |
64-
| test.cpp:256:17:256:22 | call to malloc | test.cpp:257:12:257:12 | p |
6561
| test.cpp:262:15:262:30 | call to malloc | test.cpp:266:12:266:12 | p |
66-
| test.cpp:262:22:262:27 | call to malloc | test.cpp:266:12:266:12 | p |
6762
| test.cpp:264:13:264:30 | call to malloc | test.cpp:266:12:266:12 | p |
68-
| test.cpp:264:20:264:25 | call to malloc | test.cpp:266:12:266:12 | p |
6963
nodes
7064
| test.cpp:16:11:16:21 | mk_string_t indirection [string] | semmle.label | mk_string_t indirection [string] |
7165
| test.cpp:18:5:18:30 | ... = ... | semmle.label | ... = ... |
@@ -116,29 +110,23 @@ nodes
116110
| test.cpp:214:24:214:24 | p | semmle.label | p |
117111
| test.cpp:216:10:216:10 | p | semmle.label | p |
118112
| test.cpp:220:27:220:54 | call to malloc | semmle.label | call to malloc |
119-
| test.cpp:220:43:220:48 | call to malloc | semmle.label | call to malloc |
120113
| test.cpp:222:15:222:20 | buffer | semmle.label | buffer |
121114
| test.cpp:228:27:228:54 | call to malloc | semmle.label | call to malloc |
122-
| test.cpp:228:43:228:48 | call to malloc | semmle.label | call to malloc |
123115
| test.cpp:232:10:232:15 | buffer | semmle.label | buffer |
124116
| test.cpp:235:40:235:45 | buffer | semmle.label | buffer |
125117
| test.cpp:236:5:236:26 | ... = ... | semmle.label | ... = ... |
126118
| test.cpp:236:12:236:17 | p_str indirection [post update] [string] | semmle.label | p_str indirection [post update] [string] |
127119
| test.cpp:241:20:241:38 | call to malloc | semmle.label | call to malloc |
128-
| test.cpp:241:27:241:32 | call to malloc | semmle.label | call to malloc |
129120
| test.cpp:242:16:242:19 | set_string output argument [string] | semmle.label | set_string output argument [string] |
130121
| test.cpp:242:22:242:27 | buffer | semmle.label | buffer |
131122
| test.cpp:243:12:243:14 | str indirection [string] | semmle.label | str indirection [string] |
132123
| test.cpp:243:12:243:21 | string | semmle.label | string |
133124
| test.cpp:249:14:249:33 | call to my_alloc | semmle.label | call to my_alloc |
134125
| test.cpp:250:12:250:12 | p | semmle.label | p |
135126
| test.cpp:256:9:256:25 | call to malloc | semmle.label | call to malloc |
136-
| test.cpp:256:17:256:22 | call to malloc | semmle.label | call to malloc |
137127
| test.cpp:257:12:257:12 | p | semmle.label | p |
138128
| test.cpp:262:15:262:30 | call to malloc | semmle.label | call to malloc |
139-
| test.cpp:262:22:262:27 | call to malloc | semmle.label | call to malloc |
140129
| test.cpp:264:13:264:30 | call to malloc | semmle.label | call to malloc |
141-
| test.cpp:264:20:264:25 | call to malloc | semmle.label | call to malloc |
142130
| test.cpp:266:12:266:12 | p | semmle.label | p |
143131
subpaths
144132
| test.cpp:242:22:242:27 | buffer | test.cpp:235:40:235:45 | buffer | test.cpp:236:12:236:17 | p_str indirection [post update] [string] | test.cpp:242:16:242:19 | set_string output argument [string] |
@@ -159,7 +147,5 @@ subpaths
159147
| test.cpp:203:9:203:15 | call to strncpy | test.cpp:147:19:147:24 | call to malloc | test.cpp:203:22:203:27 | string | This write may overflow $@ by 2 elements. | test.cpp:203:22:203:27 | string | string |
160148
| test.cpp:207:9:207:15 | call to strncpy | test.cpp:147:19:147:24 | call to malloc | test.cpp:207:22:207:27 | string | This write may overflow $@ by 3 elements. | test.cpp:207:22:207:27 | string | string |
161149
| test.cpp:243:5:243:10 | call to memset | test.cpp:241:20:241:38 | call to malloc | test.cpp:243:12:243:21 | string | This write may overflow $@ by 1 element. | test.cpp:243:16:243:21 | string | string |
162-
| test.cpp:243:5:243:10 | call to memset | test.cpp:241:27:241:32 | call to malloc | test.cpp:243:12:243:21 | string | This write may overflow $@ by 1 element. | test.cpp:243:16:243:21 | string | string |
163150
| test.cpp:250:5:250:10 | call to memset | test.cpp:249:14:249:33 | call to my_alloc | test.cpp:250:12:250:12 | p | This write may overflow $@ by 1 element. | test.cpp:250:12:250:12 | p | p |
164151
| test.cpp:266:5:266:10 | call to memset | test.cpp:262:15:262:30 | call to malloc | test.cpp:266:12:266:12 | p | This write may overflow $@ by 1 element. | test.cpp:266:12:266:12 | p | p |
165-
| test.cpp:266:5:266:10 | call to memset | test.cpp:262:22:262:27 | call to malloc | test.cpp:266:12:266:12 | p | This write may overflow $@ by 1 element. | test.cpp:266:12:266:12 | p | p |

0 commit comments

Comments
 (0)