mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Flow through swap.
This commit is contained in:
@@ -256,10 +256,13 @@ class StdStringSubstr extends TaintFunction {
|
||||
}
|
||||
|
||||
/**
|
||||
* The standard function `std::string.swap`.
|
||||
* The standard functions `std::string.swap` and `std::stringstream::swap`.
|
||||
*/
|
||||
class StdStringSwap extends TaintFunction {
|
||||
StdStringSwap() { this.hasQualifiedName("std", "basic_string", "swap") }
|
||||
StdStringSwap() {
|
||||
this.hasQualifiedName("std", "basic_string", "swap") or
|
||||
this.hasQualifiedName("std", "basic_stringstream", "swap")
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
// str1.swap(str2)
|
||||
|
||||
@@ -1623,9 +1623,13 @@
|
||||
| stringstream.cpp:115:24:115:32 | call to basic_stringstream | stringstream.cpp:118:2:118:4 | ss4 | |
|
||||
| stringstream.cpp:115:24:115:32 | call to basic_stringstream | stringstream.cpp:123:7:123:9 | ss4 | |
|
||||
| stringstream.cpp:117:2:117:4 | ref arg ss1 | stringstream.cpp:120:7:120:9 | ss1 | |
|
||||
| stringstream.cpp:117:2:117:4 | ss1 | stringstream.cpp:117:11:117:13 | ref arg ss2 | TAINT |
|
||||
| stringstream.cpp:117:11:117:13 | ref arg ss2 | stringstream.cpp:121:7:121:9 | ss2 | |
|
||||
| stringstream.cpp:117:11:117:13 | ss2 | stringstream.cpp:117:2:117:4 | ref arg ss1 | TAINT |
|
||||
| stringstream.cpp:118:2:118:4 | ref arg ss4 | stringstream.cpp:123:7:123:9 | ss4 | |
|
||||
| stringstream.cpp:118:2:118:4 | ss4 | stringstream.cpp:118:11:118:13 | ref arg ss3 | TAINT |
|
||||
| stringstream.cpp:118:11:118:13 | ref arg ss3 | stringstream.cpp:122:7:122:9 | ss3 | |
|
||||
| stringstream.cpp:118:11:118:13 | ss3 | stringstream.cpp:118:2:118:4 | ref arg ss4 | TAINT |
|
||||
| stringstream.cpp:128:20:128:22 | call to basic_stringstream | stringstream.cpp:142:7:142:9 | ss1 | |
|
||||
| stringstream.cpp:128:20:128:22 | call to basic_stringstream | stringstream.cpp:145:7:145:9 | ss1 | |
|
||||
| stringstream.cpp:128:20:128:22 | call to basic_stringstream | stringstream.cpp:153:7:153:9 | ss1 | |
|
||||
|
||||
@@ -117,9 +117,9 @@ void test_stringstream_swap()
|
||||
ss1.swap(ss2);
|
||||
ss4.swap(ss3);
|
||||
|
||||
sink(ss1); // tainted [NOT DETECTED]
|
||||
sink(ss1); // tainted
|
||||
sink(ss2); // [FALSE POSITIVE]
|
||||
sink(ss3); // tainted [NOT DETECTED]
|
||||
sink(ss3); // tainted
|
||||
sink(ss4); // [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,9 @@
|
||||
| stringstream.cpp:103:7:103:9 | ss2 | stringstream.cpp:91:19:91:24 | call to source |
|
||||
| stringstream.cpp:105:7:105:9 | ss4 | stringstream.cpp:95:44:95:49 | call to source |
|
||||
| stringstream.cpp:107:7:107:9 | ss6 | stringstream.cpp:100:31:100:36 | call to source |
|
||||
| stringstream.cpp:120:7:120:9 | ss1 | stringstream.cpp:113:24:113:29 | call to source |
|
||||
| stringstream.cpp:121:7:121:9 | ss2 | stringstream.cpp:113:24:113:29 | call to source |
|
||||
| stringstream.cpp:122:7:122:9 | ss3 | stringstream.cpp:115:24:115:29 | call to source |
|
||||
| stringstream.cpp:123:7:123:9 | ss4 | stringstream.cpp:115:24:115:29 | call to source |
|
||||
| stringstream.cpp:143:11:143:11 | call to operator<< | stringstream.cpp:143:14:143:19 | call to source |
|
||||
| stringstream.cpp:146:11:146:11 | call to operator>> | stringstream.cpp:143:14:143:19 | call to source |
|
||||
|
||||
@@ -196,7 +196,9 @@
|
||||
| stringstream.cpp:103:7:103:9 | stringstream.cpp:91:19:91:24 | AST only |
|
||||
| stringstream.cpp:105:7:105:9 | stringstream.cpp:95:44:95:49 | AST only |
|
||||
| stringstream.cpp:107:7:107:9 | stringstream.cpp:100:31:100:36 | AST only |
|
||||
| stringstream.cpp:120:7:120:9 | stringstream.cpp:113:24:113:29 | AST only |
|
||||
| stringstream.cpp:121:7:121:9 | stringstream.cpp:113:24:113:29 | AST only |
|
||||
| stringstream.cpp:122:7:122:9 | stringstream.cpp:115:24:115:29 | AST only |
|
||||
| stringstream.cpp:123:7:123:9 | stringstream.cpp:115:24:115:29 | AST only |
|
||||
| stringstream.cpp:143:11:143:11 | stringstream.cpp:143:14:143:21 | IR only |
|
||||
| stringstream.cpp:143:11:143:22 | stringstream.cpp:143:14:143:19 | IR only |
|
||||
|
||||
Reference in New Issue
Block a user