Skip to content

Commit 15123a7

Browse files
committed
C++: Reduce duplication.
1 parent bbd80ec commit 15123a7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cpp/ql/src/Security/CWE/CWE-022/TaintedPath.ql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ module TaintedPathConfig implements DataFlow::ConfigSig {
8888
hasUpperBoundsCheck(checkedVar)
8989
)
9090
}
91+
92+
predicate isBarrierOut(DataFlow::Node node) {
93+
// make sinks barriers so that we only report the closest instance
94+
isSink(node)
95+
}
9196
}
9297

9398
module TaintedPath = TaintTracking::Global<TaintedPathConfig>;

cpp/ql/test/query-tests/Security/CWE/CWE-022/semmle/tests/TaintedPath.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ edges
99
| test.c:48:21:48:26 | *call to getenv | test.c:48:21:48:26 | *call to getenv | provenance | |
1010
| test.c:48:21:48:26 | *call to getenv | test.c:49:11:49:17 | *tainted | provenance | |
1111
| test.c:54:21:54:26 | *call to getenv | test.c:55:11:55:16 | *buffer | provenance | TaintFunction |
12-
| test.c:54:21:54:26 | *call to getenv | test.c:56:11:56:16 | *buffer | provenance | TaintFunction |
1312
| test.c:74:13:74:18 | read output argument | test.c:76:11:76:16 | *buffer | provenance | |
1413
| test.c:75:13:75:18 | read output argument | test.c:76:11:76:16 | *buffer | provenance | |
1514
nodes
@@ -27,7 +26,6 @@ nodes
2726
| test.c:49:11:49:17 | *tainted | semmle.label | *tainted |
2827
| test.c:54:21:54:26 | *call to getenv | semmle.label | *call to getenv |
2928
| test.c:55:11:55:16 | *buffer | semmle.label | *buffer |
30-
| test.c:56:11:56:16 | *buffer | semmle.label | *buffer |
3129
| test.c:69:14:69:20 | *access to array | semmle.label | *access to array |
3230
| test.c:74:13:74:18 | read output argument | semmle.label | read output argument |
3331
| test.c:75:13:75:18 | read output argument | semmle.label | read output argument |
@@ -40,7 +38,6 @@ subpaths
4038
| test.c:44:11:44:18 | fileName | test.c:43:17:43:24 | scanf output argument | test.c:44:11:44:18 | *fileName | This argument to a file access function is derived from $@ and then passed to fopen(filename). | test.c:43:17:43:24 | scanf output argument | user input (value read by scanf) |
4139
| test.c:49:11:49:17 | tainted | test.c:48:21:48:26 | *call to getenv | test.c:49:11:49:17 | *tainted | This argument to a file access function is derived from $@ and then passed to fopen(filename). | test.c:48:21:48:26 | *call to getenv | user input (an environment variable) |
4240
| test.c:55:11:55:16 | buffer | test.c:54:21:54:26 | *call to getenv | test.c:55:11:55:16 | *buffer | This argument to a file access function is derived from $@ and then passed to fopen(filename). | test.c:54:21:54:26 | *call to getenv | user input (an environment variable) |
43-
| test.c:56:11:56:16 | buffer | test.c:54:21:54:26 | *call to getenv | test.c:56:11:56:16 | *buffer | This argument to a file access function is derived from $@ and then passed to fopen(filename). | test.c:54:21:54:26 | *call to getenv | user input (an environment variable) |
4441
| test.c:69:14:69:20 | access to array | test.c:8:27:8:30 | **argv | test.c:69:14:69:20 | *access to array | This argument to a file access function is derived from $@ and then passed to readFile(fileName), which calls fopen(filename). | test.c:8:27:8:30 | **argv | user input (a command-line argument) |
4542
| test.c:76:11:76:16 | buffer | test.c:74:13:74:18 | read output argument | test.c:76:11:76:16 | *buffer | This argument to a file access function is derived from $@ and then passed to fopen(filename). | test.c:74:13:74:18 | read output argument | user input (buffer read by read) |
4643
| test.c:76:11:76:16 | buffer | test.c:75:13:75:18 | read output argument | test.c:76:11:76:16 | *buffer | This argument to a file access function is derived from $@ and then passed to fopen(filename). | test.c:75:13:75:18 | read output argument | user input (buffer read by read) |

0 commit comments

Comments
 (0)