Skip to content

Commit 76c2d24

Browse files
committed
C++: Add summary for ReadFileEx and accept test changes.
1 parent c1ee56e commit 76c2d24

File tree

4 files changed

+74
-14
lines changed

4 files changed

+74
-14
lines changed

cpp/ql/lib/ext/Windows.model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ extensions:
3131
# shellapi.h
3232
- ["", "", False, "CommandLineToArgvA", "", "", "Argument[*0]", "ReturnValue[**]", "taint", "manual"]
3333
- ["", "", False, "CommandLineToArgvW", "", "", "Argument[*0]", "ReturnValue[**]", "taint", "manual"]
34+
# fileapi.h
35+
- ["", "", False, "ReadFileEx", "", "", "Argument[*3].Field[@hEvent]", "Argument[4].Parameter[*2].Field[@hEvent]", "value", "manual"]

cpp/ql/test/library-tests/dataflow/external-models/flow.expected

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@ edges
1010
| asio_streams.cpp:100:44:100:62 | call to buffer | asio_streams.cpp:103:29:103:39 | *send_buffer | provenance | Sink:MaD:6 |
1111
| asio_streams.cpp:100:64:100:71 | *send_str | asio_streams.cpp:56:18:56:23 | [summary param] *0 in buffer | provenance | |
1212
| asio_streams.cpp:100:64:100:71 | *send_str | asio_streams.cpp:100:44:100:62 | call to buffer | provenance | MaD:10 |
13-
| test.cpp:4:5:4:17 | [summary param] 0 in ymlStepManual | test.cpp:4:5:4:17 | [summary] to write: ReturnValue in ymlStepManual | provenance | MaD:23507 |
14-
| test.cpp:5:5:5:20 | [summary param] 0 in ymlStepGenerated | test.cpp:5:5:5:20 | [summary] to write: ReturnValue in ymlStepGenerated | provenance | MaD:23508 |
15-
| test.cpp:6:5:6:27 | [summary param] 0 in ymlStepManual_with_body | test.cpp:6:5:6:27 | [summary] to write: ReturnValue in ymlStepManual_with_body | provenance | MaD:23509 |
13+
| test.cpp:4:5:4:17 | [summary param] 0 in ymlStepManual | test.cpp:4:5:4:17 | [summary] to write: ReturnValue in ymlStepManual | provenance | MaD:23508 |
14+
| test.cpp:5:5:5:20 | [summary param] 0 in ymlStepGenerated | test.cpp:5:5:5:20 | [summary] to write: ReturnValue in ymlStepGenerated | provenance | MaD:23509 |
15+
| test.cpp:6:5:6:27 | [summary param] 0 in ymlStepManual_with_body | test.cpp:6:5:6:27 | [summary] to write: ReturnValue in ymlStepManual_with_body | provenance | MaD:23510 |
1616
| test.cpp:7:47:7:52 | value2 | test.cpp:7:64:7:69 | value2 | provenance | |
1717
| test.cpp:7:64:7:69 | value2 | test.cpp:7:5:7:30 | *ymlStepGenerated_with_body | provenance | |
18-
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:10:10:10:18 | call to ymlSource | provenance | Src:MaD:23505 |
19-
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:14:10:14:10 | x | provenance | Sink:MaD:23506 |
18+
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:10:10:10:18 | call to ymlSource | provenance | Src:MaD:23506 |
19+
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:14:10:14:10 | x | provenance | Sink:MaD:23507 |
2020
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:17:24:17:24 | x | provenance | |
2121
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:21:27:21:27 | x | provenance | |
2222
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:25:35:25:35 | x | provenance | |
2323
| test.cpp:10:10:10:18 | call to ymlSource | test.cpp:32:41:32:41 | x | provenance | |
2424
| test.cpp:17:10:17:22 | call to ymlStepManual | test.cpp:17:10:17:22 | call to ymlStepManual | provenance | |
25-
| test.cpp:17:10:17:22 | call to ymlStepManual | test.cpp:18:10:18:10 | y | provenance | Sink:MaD:23506 |
25+
| test.cpp:17:10:17:22 | call to ymlStepManual | test.cpp:18:10:18:10 | y | provenance | Sink:MaD:23507 |
2626
| test.cpp:17:24:17:24 | x | test.cpp:4:5:4:17 | [summary param] 0 in ymlStepManual | provenance | |
27-
| test.cpp:17:24:17:24 | x | test.cpp:17:10:17:22 | call to ymlStepManual | provenance | MaD:23507 |
27+
| test.cpp:17:24:17:24 | x | test.cpp:17:10:17:22 | call to ymlStepManual | provenance | MaD:23508 |
2828
| test.cpp:21:10:21:25 | call to ymlStepGenerated | test.cpp:21:10:21:25 | call to ymlStepGenerated | provenance | |
29-
| test.cpp:21:10:21:25 | call to ymlStepGenerated | test.cpp:22:10:22:10 | z | provenance | Sink:MaD:23506 |
29+
| test.cpp:21:10:21:25 | call to ymlStepGenerated | test.cpp:22:10:22:10 | z | provenance | Sink:MaD:23507 |
3030
| test.cpp:21:27:21:27 | x | test.cpp:5:5:5:20 | [summary param] 0 in ymlStepGenerated | provenance | |
31-
| test.cpp:21:27:21:27 | x | test.cpp:21:10:21:25 | call to ymlStepGenerated | provenance | MaD:23508 |
31+
| test.cpp:21:27:21:27 | x | test.cpp:21:10:21:25 | call to ymlStepGenerated | provenance | MaD:23509 |
3232
| test.cpp:25:11:25:33 | call to ymlStepManual_with_body | test.cpp:25:11:25:33 | call to ymlStepManual_with_body | provenance | |
33-
| test.cpp:25:11:25:33 | call to ymlStepManual_with_body | test.cpp:26:10:26:11 | y2 | provenance | Sink:MaD:23506 |
33+
| test.cpp:25:11:25:33 | call to ymlStepManual_with_body | test.cpp:26:10:26:11 | y2 | provenance | Sink:MaD:23507 |
3434
| test.cpp:25:35:25:35 | x | test.cpp:6:5:6:27 | [summary param] 0 in ymlStepManual_with_body | provenance | |
35-
| test.cpp:25:35:25:35 | x | test.cpp:25:11:25:33 | call to ymlStepManual_with_body | provenance | MaD:23509 |
35+
| test.cpp:25:35:25:35 | x | test.cpp:25:11:25:33 | call to ymlStepManual_with_body | provenance | MaD:23510 |
3636
| test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body | test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body | provenance | |
37-
| test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body | test.cpp:33:10:33:11 | z2 | provenance | Sink:MaD:23506 |
37+
| test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body | test.cpp:33:10:33:11 | z2 | provenance | Sink:MaD:23507 |
3838
| test.cpp:32:41:32:41 | x | test.cpp:7:47:7:52 | value2 | provenance | |
3939
| test.cpp:32:41:32:41 | x | test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body | provenance | |
4040
| windows.cpp:6:8:6:25 | [summary param] *0 in CommandLineToArgvA | windows.cpp:6:8:6:25 | [summary] to write: ReturnValue[**] in CommandLineToArgvA | provenance | MaD:341 |
@@ -48,8 +48,35 @@ edges
4848
| windows.cpp:23:17:23:38 | *call to GetEnvironmentStringsA | windows.cpp:23:17:23:38 | *call to GetEnvironmentStringsA | provenance | Src:MaD:327 |
4949
| windows.cpp:23:17:23:38 | *call to GetEnvironmentStringsA | windows.cpp:25:10:25:13 | * ... | provenance | |
5050
| windows.cpp:28:36:28:38 | GetEnvironmentVariableA output argument | windows.cpp:30:10:30:13 | * ... | provenance | Src:MaD:329 |
51+
| windows.cpp:86:6:86:15 | [summary param] *3 in ReadFileEx [*hEvent] | windows.cpp:86:6:86:15 | [summary] read: Argument[*3].Field[*hEvent] in ReadFileEx | provenance | |
52+
| windows.cpp:86:6:86:15 | [summary param] *3 in ReadFileEx [hEvent] | windows.cpp:86:6:86:15 | [summary] read: Argument[*3].Field[hEvent] in ReadFileEx | provenance | |
53+
| windows.cpp:86:6:86:15 | [summary] read: Argument[*3].Field[*hEvent] in ReadFileEx | windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2].Field[*hEvent] in ReadFileEx | provenance | MaD:343 |
54+
| windows.cpp:86:6:86:15 | [summary] read: Argument[*3].Field[hEvent] in ReadFileEx | windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2].Field[hEvent] in ReadFileEx | provenance | MaD:343 |
55+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [*hEvent] | windows.cpp:143:16:143:27 | *lpOverlapped [*hEvent] | provenance | |
56+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [hEvent] | windows.cpp:153:16:153:27 | *lpOverlapped [hEvent] | provenance | |
57+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2].Field[*hEvent] in ReadFileEx | windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [*hEvent] | provenance | |
58+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2].Field[hEvent] in ReadFileEx | windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [hEvent] | provenance | |
59+
| windows.cpp:143:16:143:27 | *lpOverlapped [*hEvent] | windows.cpp:145:42:145:53 | *lpOverlapped [*hEvent] | provenance | |
60+
| windows.cpp:145:18:145:62 | *hEvent | windows.cpp:145:18:145:62 | *hEvent | provenance | |
61+
| windows.cpp:145:18:145:62 | *hEvent | windows.cpp:147:8:147:14 | * ... | provenance | |
62+
| windows.cpp:145:42:145:53 | *lpOverlapped [*hEvent] | windows.cpp:145:18:145:62 | *hEvent | provenance | |
63+
| windows.cpp:145:42:145:53 | *lpOverlapped [*hEvent] | windows.cpp:145:56:145:61 | *hEvent | provenance | |
64+
| windows.cpp:145:56:145:61 | *hEvent | windows.cpp:145:18:145:62 | *hEvent | provenance | |
65+
| windows.cpp:153:16:153:27 | *lpOverlapped [hEvent] | windows.cpp:155:35:155:46 | *lpOverlapped [hEvent] | provenance | |
66+
| windows.cpp:155:12:155:55 | hEvent | windows.cpp:155:12:155:55 | hEvent | provenance | |
67+
| windows.cpp:155:12:155:55 | hEvent | windows.cpp:156:8:156:8 | c | provenance | |
68+
| windows.cpp:155:35:155:46 | *lpOverlapped [hEvent] | windows.cpp:155:12:155:55 | hEvent | provenance | |
69+
| windows.cpp:155:35:155:46 | *lpOverlapped [hEvent] | windows.cpp:155:12:155:55 | hEvent | provenance | |
5170
| windows.cpp:164:35:164:40 | ReadFile output argument | windows.cpp:166:10:166:16 | * ... | provenance | Src:MaD:331 |
5271
| windows.cpp:173:23:173:28 | ReadFileEx output argument | windows.cpp:175:10:175:16 | * ... | provenance | Src:MaD:332 |
72+
| windows.cpp:185:21:185:26 | ReadFile output argument | windows.cpp:186:5:186:56 | *... = ... | provenance | Src:MaD:331 |
73+
| windows.cpp:186:5:186:14 | *overlapped [post update] [*hEvent] | windows.cpp:188:53:188:63 | *& ... [*hEvent] | provenance | |
74+
| windows.cpp:186:5:186:56 | *... = ... | windows.cpp:186:5:186:14 | *overlapped [post update] [*hEvent] | provenance | |
75+
| windows.cpp:188:53:188:63 | *& ... [*hEvent] | windows.cpp:86:6:86:15 | [summary param] *3 in ReadFileEx [*hEvent] | provenance | |
76+
| windows.cpp:194:21:194:26 | ReadFile output argument | windows.cpp:195:5:195:57 | ... = ... | provenance | Src:MaD:331 |
77+
| windows.cpp:195:5:195:14 | *overlapped [post update] [hEvent] | windows.cpp:197:53:197:63 | *& ... [hEvent] | provenance | |
78+
| windows.cpp:195:5:195:57 | ... = ... | windows.cpp:195:5:195:14 | *overlapped [post update] [hEvent] | provenance | |
79+
| windows.cpp:197:53:197:63 | *& ... [hEvent] | windows.cpp:86:6:86:15 | [summary param] *3 in ReadFileEx [hEvent] | provenance | |
5380
| windows.cpp:205:84:205:89 | NtReadFile output argument | windows.cpp:207:10:207:16 | * ... | provenance | Src:MaD:340 |
5481
| windows.cpp:282:23:282:35 | *call to MapViewOfFile | windows.cpp:282:23:282:35 | *call to MapViewOfFile | provenance | Src:MaD:333 |
5582
| windows.cpp:282:23:282:35 | *call to MapViewOfFile | windows.cpp:283:20:283:52 | *pMapView | provenance | |
@@ -127,10 +154,37 @@ nodes
127154
| windows.cpp:25:10:25:13 | * ... | semmle.label | * ... |
128155
| windows.cpp:28:36:28:38 | GetEnvironmentVariableA output argument | semmle.label | GetEnvironmentVariableA output argument |
129156
| windows.cpp:30:10:30:13 | * ... | semmle.label | * ... |
157+
| windows.cpp:86:6:86:15 | [summary param] *3 in ReadFileEx [*hEvent] | semmle.label | [summary param] *3 in ReadFileEx [*hEvent] |
158+
| windows.cpp:86:6:86:15 | [summary param] *3 in ReadFileEx [hEvent] | semmle.label | [summary param] *3 in ReadFileEx [hEvent] |
159+
| windows.cpp:86:6:86:15 | [summary] read: Argument[*3].Field[*hEvent] in ReadFileEx | semmle.label | [summary] read: Argument[*3].Field[*hEvent] in ReadFileEx |
160+
| windows.cpp:86:6:86:15 | [summary] read: Argument[*3].Field[hEvent] in ReadFileEx | semmle.label | [summary] read: Argument[*3].Field[hEvent] in ReadFileEx |
161+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [*hEvent] | semmle.label | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [*hEvent] |
162+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [hEvent] | semmle.label | [summary] to write: Argument[4].Parameter[*2] in ReadFileEx [hEvent] |
163+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2].Field[*hEvent] in ReadFileEx | semmle.label | [summary] to write: Argument[4].Parameter[*2].Field[*hEvent] in ReadFileEx |
164+
| windows.cpp:86:6:86:15 | [summary] to write: Argument[4].Parameter[*2].Field[hEvent] in ReadFileEx | semmle.label | [summary] to write: Argument[4].Parameter[*2].Field[hEvent] in ReadFileEx |
165+
| windows.cpp:143:16:143:27 | *lpOverlapped [*hEvent] | semmle.label | *lpOverlapped [*hEvent] |
166+
| windows.cpp:145:18:145:62 | *hEvent | semmle.label | *hEvent |
167+
| windows.cpp:145:18:145:62 | *hEvent | semmle.label | *hEvent |
168+
| windows.cpp:145:42:145:53 | *lpOverlapped [*hEvent] | semmle.label | *lpOverlapped [*hEvent] |
169+
| windows.cpp:145:56:145:61 | *hEvent | semmle.label | *hEvent |
170+
| windows.cpp:147:8:147:14 | * ... | semmle.label | * ... |
171+
| windows.cpp:153:16:153:27 | *lpOverlapped [hEvent] | semmle.label | *lpOverlapped [hEvent] |
172+
| windows.cpp:155:12:155:55 | hEvent | semmle.label | hEvent |
173+
| windows.cpp:155:12:155:55 | hEvent | semmle.label | hEvent |
174+
| windows.cpp:155:35:155:46 | *lpOverlapped [hEvent] | semmle.label | *lpOverlapped [hEvent] |
175+
| windows.cpp:156:8:156:8 | c | semmle.label | c |
130176
| windows.cpp:164:35:164:40 | ReadFile output argument | semmle.label | ReadFile output argument |
131177
| windows.cpp:166:10:166:16 | * ... | semmle.label | * ... |
132178
| windows.cpp:173:23:173:28 | ReadFileEx output argument | semmle.label | ReadFileEx output argument |
133179
| windows.cpp:175:10:175:16 | * ... | semmle.label | * ... |
180+
| windows.cpp:185:21:185:26 | ReadFile output argument | semmle.label | ReadFile output argument |
181+
| windows.cpp:186:5:186:14 | *overlapped [post update] [*hEvent] | semmle.label | *overlapped [post update] [*hEvent] |
182+
| windows.cpp:186:5:186:56 | *... = ... | semmle.label | *... = ... |
183+
| windows.cpp:188:53:188:63 | *& ... [*hEvent] | semmle.label | *& ... [*hEvent] |
184+
| windows.cpp:194:21:194:26 | ReadFile output argument | semmle.label | ReadFile output argument |
185+
| windows.cpp:195:5:195:14 | *overlapped [post update] [hEvent] | semmle.label | *overlapped [post update] [hEvent] |
186+
| windows.cpp:195:5:195:57 | ... = ... | semmle.label | ... = ... |
187+
| windows.cpp:197:53:197:63 | *& ... [hEvent] | semmle.label | *& ... [hEvent] |
134188
| windows.cpp:205:84:205:89 | NtReadFile output argument | semmle.label | NtReadFile output argument |
135189
| windows.cpp:207:10:207:16 | * ... | semmle.label | * ... |
136190
| windows.cpp:282:23:282:35 | *call to MapViewOfFile | semmle.label | *call to MapViewOfFile |

cpp/ql/test/library-tests/dataflow/external-models/validatemodels.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3771,3 +3771,7 @@
37713771
| Dubious signature "(wchar_t *)" in summary model. |
37723772
| Dubious signature "(wchar_t, const CStringT &)" in summary model. |
37733773
| Dubious signature "(wchar_t,const CStringT &)" in summary model. |
3774+
| Unrecognized input specification "Field[****hEvent]" in summary model. |
3775+
| Unrecognized input specification "Field[***hEvent]" in summary model. |
3776+
| Unrecognized output specification "Field[****hEvent]" in summary model. |
3777+
| Unrecognized output specification "Field[***hEvent]" in summary model. |

cpp/ql/test/library-tests/dataflow/external-models/windows.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void FileIOCompletionRoutine2(
144144
) {
145145
char* buffer = reinterpret_cast<char*>(lpOverlapped->hEvent);
146146
sink(buffer);
147-
sink(*buffer); // $ MISSING: ir
147+
sink(*buffer); // $ ir
148148
}
149149

150150
void FileIOCompletionRoutine3(
@@ -153,7 +153,7 @@ void FileIOCompletionRoutine3(
153153
LPOVERLAPPED lpOverlapped
154154
) {
155155
char c = reinterpret_cast<char>(lpOverlapped->hEvent);
156-
sink(c); // $ MISSING: ir
156+
sink(c); // $ ir
157157
}
158158

159159
void readFile(HANDLE hFile) {

0 commit comments

Comments
 (0)