Skip to content

Commit de97ae3

Browse files
committed
C++: C++: Use getAUse in getIRRepresentationOfIndirectOperand
1 parent 30ad113 commit de97ae3

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ private module Cached {
765765
Operand getIRRepresentationOfIndirectOperand(Operand operand, int indirectionIndex) {
766766
exists(Instruction load |
767767
isDereference(load, operand) and
768-
result = unique( | | load.getAUse()) and
768+
result = unique( | | getAUse(load)) and
769769
isUseImpl(operand, _, indirectionIndex - 1)
770770
)
771771
}

cpp/ql/test/query-tests/Security/CWE/CWE-134/semmle/globalVars/UncontrolledFormatStringThroughGlobalVar.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ edges
2525
| globalVars.c:16:2:16:12 | ... = ... | globalVars.c:9:7:9:11 | copy2 |
2626
| globalVars.c:24:11:24:14 | argv | globalVars.c:11:22:11:25 | argv |
2727
| globalVars.c:24:11:24:14 | argv | globalVars.c:11:22:11:25 | argv |
28+
| globalVars.c:30:15:30:18 | copy | globalVars.c:30:15:30:18 | copy |
29+
| globalVars.c:30:15:30:18 | copy | globalVars.c:30:15:30:18 | copy |
30+
| globalVars.c:30:15:30:18 | copy | globalVars.c:30:15:30:18 | copy |
2831
| globalVars.c:30:15:30:18 | copy | globalVars.c:35:11:35:14 | copy |
2932
| globalVars.c:33:15:33:18 | copy | globalVars.c:35:11:35:14 | copy |
3033
| globalVars.c:35:11:35:14 | copy | globalVars.c:15:21:15:23 | val |
34+
| globalVars.c:35:11:35:14 | copy | globalVars.c:35:11:35:14 | copy |
35+
| globalVars.c:41:15:41:19 | copy2 | globalVars.c:41:15:41:19 | copy2 |
36+
| globalVars.c:41:15:41:19 | copy2 | globalVars.c:41:15:41:19 | copy2 |
37+
| globalVars.c:41:15:41:19 | copy2 | globalVars.c:41:15:41:19 | copy2 |
3138
| globalVars.c:41:15:41:19 | copy2 | globalVars.c:50:9:50:13 | copy2 |
3239
| globalVars.c:41:15:41:19 | copy2 | globalVars.c:50:9:50:13 | copy2 |
3340
| globalVars.c:41:15:41:19 | copy2 | globalVars.c:50:9:50:13 | copy2 |

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/CleartextBufferWrite.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
edges
2-
| test.cpp:53:27:53:30 | argv | test.cpp:58:25:58:29 | input indirection |
3-
| test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection |
42
| test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection |
53
| test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection |
64
| test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection |
75
| test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection |
86
nodes
97
| test2.cpp:110:3:110:6 | call to gets indirection | semmle.label | call to gets indirection |
10-
| test.cpp:53:27:53:30 | argv | semmle.label | argv |
118
| test.cpp:53:27:53:30 | argv indirection | semmle.label | argv indirection |
129
| test.cpp:53:27:53:30 | argv indirection | semmle.label | argv indirection |
1310
| test.cpp:58:25:58:29 | input indirection | semmle.label | input indirection |
1411
| test.cpp:58:25:58:29 | input indirection | semmle.label | input indirection |
15-
| test.cpp:58:25:58:29 | input indirection | semmle.label | input indirection |
1612
subpaths
1713
#select
1814
| test2.cpp:110:3:110:6 | call to gets | test2.cpp:110:3:110:6 | call to gets indirection | test2.cpp:110:3:110:6 | call to gets indirection | This write into buffer 'password' may contain unencrypted data from $@. | test2.cpp:110:3:110:6 | call to gets indirection | user input (string read by gets) |
19-
| test.cpp:58:3:58:9 | call to sprintf | test.cpp:53:27:53:30 | argv | test.cpp:58:25:58:29 | input indirection | This write into buffer 'passwd' may contain unencrypted data from $@. | test.cpp:53:27:53:30 | argv | user input (a command-line argument) |
20-
| test.cpp:58:3:58:9 | call to sprintf | test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection | This write into buffer 'passwd' may contain unencrypted data from $@. | test.cpp:53:27:53:30 | argv indirection | user input (a command-line argument) |
2115
| test.cpp:58:3:58:9 | call to sprintf | test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection | This write into buffer 'passwd' may contain unencrypted data from $@. | test.cpp:53:27:53:30 | argv indirection | user input (a command-line argument) |
2216
| test.cpp:58:3:58:9 | call to sprintf | test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection | This write into buffer 'passwd' may contain unencrypted data from $@. | test.cpp:53:27:53:30 | argv indirection | user input (a command-line argument) |
2317
| test.cpp:58:3:58:9 | call to sprintf | test.cpp:53:27:53:30 | argv indirection | test.cpp:58:25:58:29 | input indirection | This write into buffer 'passwd' may contain unencrypted data from $@. | test.cpp:53:27:53:30 | argv indirection | user input (a command-line argument) |

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/CleartextFileWrite.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
edges
22
| test2.cpp:62:18:62:25 | password | test2.cpp:65:31:65:34 | cpy1 |
3-
| test2.cpp:62:18:62:25 | password | test2.cpp:65:31:65:34 | cpy1 indirection |
43
| test2.cpp:72:15:72:24 | password | test2.cpp:73:30:73:32 | buf indirection |
54
| test2.cpp:72:15:72:24 | password | test2.cpp:76:30:76:32 | buf indirection |
65
| test2.cpp:72:17:72:24 | password | test2.cpp:73:30:73:32 | buf indirection |
@@ -28,7 +27,6 @@ nodes
2827
| test2.cpp:57:39:57:49 | call to getPassword | semmle.label | call to getPassword |
2928
| test2.cpp:62:18:62:25 | password | semmle.label | password |
3029
| test2.cpp:65:31:65:34 | cpy1 | semmle.label | cpy1 |
31-
| test2.cpp:65:31:65:34 | cpy1 indirection | semmle.label | cpy1 indirection |
3230
| test2.cpp:72:15:72:24 | password | semmle.label | password |
3331
| test2.cpp:72:17:72:24 | password | semmle.label | password |
3432
| test2.cpp:73:30:73:32 | buf indirection | semmle.label | buf indirection |
@@ -57,7 +55,6 @@ subpaths
5755
| test2.cpp:55:2:55:8 | call to fprintf | test2.cpp:55:40:55:51 | widepassword | test2.cpp:55:40:55:51 | widepassword | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:55:40:55:51 | widepassword | this source. |
5856
| test2.cpp:57:2:57:8 | call to fprintf | test2.cpp:57:39:57:49 | call to getPassword | test2.cpp:57:39:57:49 | call to getPassword | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:57:39:57:49 | call to getPassword | this source. |
5957
| test2.cpp:65:3:65:9 | call to fprintf | test2.cpp:62:18:62:25 | password | test2.cpp:65:31:65:34 | cpy1 | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:62:18:62:25 | password | this source. |
60-
| test2.cpp:65:3:65:9 | call to fprintf | test2.cpp:62:18:62:25 | password | test2.cpp:65:31:65:34 | cpy1 indirection | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:62:18:62:25 | password | this source. |
6158
| test2.cpp:73:3:73:9 | call to fprintf | test2.cpp:72:15:72:24 | password | test2.cpp:73:30:73:32 | buf indirection | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:72:17:72:24 | password | this source. |
6259
| test2.cpp:73:3:73:9 | call to fprintf | test2.cpp:72:17:72:24 | password | test2.cpp:73:30:73:32 | buf indirection | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:72:17:72:24 | password | this source. |
6360
| test2.cpp:76:3:76:9 | call to fprintf | test2.cpp:72:15:72:24 | password | test2.cpp:76:30:76:32 | buf indirection | This write into file 'log' may contain unencrypted data from $@. | test2.cpp:72:17:72:24 | password | this source. |

cpp/ql/test/query-tests/Security/CWE/CWE-319/UseOfHttp/UseOfHttp.expected

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
edges
2-
| test.cpp:11:26:11:28 | url | test.cpp:15:30:15:32 | url indirection |
32
| test.cpp:11:26:11:28 | url indirection | test.cpp:15:30:15:32 | url indirection |
43
| test.cpp:11:26:11:28 | url indirection | test.cpp:15:30:15:32 | url indirection |
54
| test.cpp:24:13:24:17 | url_g indirection | test.cpp:38:11:38:15 | url_g indirection |
@@ -17,20 +16,14 @@ edges
1716
| test.cpp:46:18:46:26 | http:// indirection | test.cpp:49:11:49:16 | buffer indirection |
1817
| test.cpp:46:18:46:26 | http:// indirection | test.cpp:49:11:49:16 | buffer indirection |
1918
| test.cpp:49:11:49:16 | buffer indirection | test.cpp:11:26:11:28 | url indirection |
20-
| test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:121:11:121:13 | ptr |
21-
| test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:121:11:121:13 | ptr |
22-
| test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:121:11:121:13 | ptr |
2319
| test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:121:11:121:13 | ptr indirection |
2420
| test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:121:11:121:13 | ptr indirection |
2521
| test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:121:11:121:13 | ptr indirection |
26-
| test.cpp:121:11:121:13 | ptr | test.cpp:11:26:11:28 | url |
2722
| test.cpp:121:11:121:13 | ptr indirection | test.cpp:11:26:11:28 | url indirection |
2823
nodes
29-
| test.cpp:11:26:11:28 | url | semmle.label | url |
3024
| test.cpp:11:26:11:28 | url indirection | semmle.label | url indirection |
3125
| test.cpp:15:30:15:32 | url indirection | semmle.label | url indirection |
3226
| test.cpp:15:30:15:32 | url indirection | semmle.label | url indirection |
33-
| test.cpp:15:30:15:32 | url indirection | semmle.label | url indirection |
3427
| test.cpp:24:13:24:17 | url_g indirection | semmle.label | url_g indirection |
3528
| test.cpp:24:21:24:40 | http://example.com indirection | semmle.label | http://example.com indirection |
3629
| test.cpp:24:21:24:40 | http://example.com indirection | semmle.label | http://example.com indirection |
@@ -49,7 +42,6 @@ nodes
4942
| test.cpp:110:21:110:40 | http://example.com indirection | semmle.label | http://example.com indirection |
5043
| test.cpp:110:21:110:40 | http://example.com indirection | semmle.label | http://example.com indirection |
5144
| test.cpp:110:21:110:40 | http://example.com indirection | semmle.label | http://example.com indirection |
52-
| test.cpp:121:11:121:13 | ptr | semmle.label | ptr |
5345
| test.cpp:121:11:121:13 | ptr indirection | semmle.label | ptr indirection |
5446
subpaths
5547
#select
@@ -79,6 +71,3 @@ subpaths
7971
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:15:30:15:32 | url indirection | This URL may be constructed with the HTTP protocol. |
8072
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:15:30:15:32 | url indirection | This URL may be constructed with the HTTP protocol. |
8173
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:15:30:15:32 | url indirection | This URL may be constructed with the HTTP protocol. |
82-
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:15:30:15:32 | url indirection | This URL may be constructed with the HTTP protocol. |
83-
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:15:30:15:32 | url indirection | This URL may be constructed with the HTTP protocol. |
84-
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com indirection | test.cpp:15:30:15:32 | url indirection | This URL may be constructed with the HTTP protocol. |

cpp/ql/test/query-tests/Security/CWE/CWE-497/semmle/tests/ExposedSystemData.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ edges
99
| tests2.cpp:78:18:78:38 | call to mysql_get_client_info indirection | tests2.cpp:81:14:81:19 | buffer indirection |
1010
| tests2.cpp:91:42:91:45 | str1 indirection | tests2.cpp:93:14:93:17 | str1 indirection |
1111
| tests2.cpp:91:42:91:45 | str1 indirection | tests2.cpp:93:14:93:17 | str1 indirection |
12-
| tests2.cpp:91:42:91:45 | str1 indirection | tests2.cpp:93:14:93:17 | str1 indirection |
1312
| tests2.cpp:101:8:101:15 | call to getpwuid indirection | tests2.cpp:102:14:102:15 | pw indirection |
1413
| tests2.cpp:101:8:101:15 | call to getpwuid indirection | tests2.cpp:102:14:102:15 | pw indirection |
1514
| tests2.cpp:109:3:109:36 | ... = ... indirection | tests2.cpp:109:6:109:8 | c1 indirection [post update] [ptr indirection] |
@@ -55,8 +54,6 @@ nodes
5554
| tests2.cpp:82:14:82:20 | global1 indirection | semmle.label | global1 indirection |
5655
| tests2.cpp:82:14:82:20 | global1 indirection | semmle.label | global1 indirection |
5756
| tests2.cpp:91:42:91:45 | str1 indirection | semmle.label | str1 indirection |
58-
| tests2.cpp:91:42:91:45 | str1 indirection | semmle.label | str1 indirection |
59-
| tests2.cpp:93:14:93:17 | str1 indirection | semmle.label | str1 indirection |
6057
| tests2.cpp:93:14:93:17 | str1 indirection | semmle.label | str1 indirection |
6158
| tests2.cpp:93:14:93:17 | str1 indirection | semmle.label | str1 indirection |
6259
| tests2.cpp:101:8:101:15 | call to getpwuid indirection | semmle.label | call to getpwuid indirection |
@@ -103,7 +100,6 @@ subpaths
103100
| tests2.cpp:82:14:82:20 | global1 indirection | tests2.cpp:50:23:50:43 | call to mysql_get_client_info indirection | tests2.cpp:82:14:82:20 | global1 indirection | This operation exposes system data from $@. | tests2.cpp:50:23:50:43 | call to mysql_get_client_info indirection | call to mysql_get_client_info indirection |
104101
| tests2.cpp:93:14:93:17 | str1 indirection | tests2.cpp:91:42:91:45 | str1 indirection | tests2.cpp:93:14:93:17 | str1 indirection | This operation exposes system data from $@. | tests2.cpp:91:42:91:45 | str1 indirection | str1 indirection |
105102
| tests2.cpp:93:14:93:17 | str1 indirection | tests2.cpp:91:42:91:45 | str1 indirection | tests2.cpp:93:14:93:17 | str1 indirection | This operation exposes system data from $@. | tests2.cpp:91:42:91:45 | str1 indirection | str1 indirection |
106-
| tests2.cpp:93:14:93:17 | str1 indirection | tests2.cpp:91:42:91:45 | str1 indirection | tests2.cpp:93:14:93:17 | str1 indirection | This operation exposes system data from $@. | tests2.cpp:91:42:91:45 | str1 indirection | str1 indirection |
107103
| tests2.cpp:102:14:102:15 | pw indirection | tests2.cpp:101:8:101:15 | call to getpwuid indirection | tests2.cpp:102:14:102:15 | pw indirection | This operation exposes system data from $@. | tests2.cpp:101:8:101:15 | call to getpwuid indirection | call to getpwuid indirection |
108104
| tests2.cpp:102:14:102:15 | pw indirection | tests2.cpp:101:8:101:15 | call to getpwuid indirection | tests2.cpp:102:14:102:15 | pw indirection | This operation exposes system data from $@. | tests2.cpp:101:8:101:15 | call to getpwuid indirection | call to getpwuid indirection |
109105
| tests2.cpp:111:14:111:19 | ptr indirection | tests2.cpp:109:12:109:17 | call to getenv indirection | tests2.cpp:111:14:111:19 | ptr indirection | This operation exposes system data from $@. | tests2.cpp:109:12:109:17 | call to getenv indirection | call to getenv indirection |

0 commit comments

Comments
 (0)