Skip to content

Commit a839f1f

Browse files
committed
C++: Split off stringstream.cpp.
1 parent 49d2f66 commit a839f1f

File tree

6 files changed

+328
-320
lines changed

6 files changed

+328
-320
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 224 additions & 224 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/dataflow/taint-tests/string.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ char *user_input() {
1616

1717
void sink(const char *s) {};
1818
void sink(const std::string &s) {};
19-
void sink(const std::stringstream &s) {};
2019
void sink(const char *filename, const char *mode);
2120
void sink(char) {}
2221

@@ -33,42 +32,6 @@ void test_string()
3332
sink(c.c_str()); // tainted
3433
}
3534

36-
void test_stringstream()
37-
{
38-
std::stringstream ss1, ss2, ss3, ss4, ss5;
39-
std::string t(source());
40-
41-
ss1 << "1234";
42-
ss2 << source();
43-
ss3 << "123" << source();
44-
ss4 << source() << "456";
45-
ss5 << t;
46-
47-
sink(ss1);
48-
sink(ss2); // tainted [NOT DETECTED]
49-
sink(ss3); // tainted [NOT DETECTED]
50-
sink(ss4); // tainted [NOT DETECTED]
51-
sink(ss5); // tainted [NOT DETECTED]
52-
sink(ss1.str());
53-
sink(ss2.str()); // tainted [NOT DETECTED]
54-
sink(ss3.str()); // tainted [NOT DETECTED]
55-
sink(ss4.str()); // tainted [NOT DETECTED]
56-
sink(ss5.str()); // tainted [NOT DETECTED]
57-
}
58-
59-
void test_stringstream_int(int source)
60-
{
61-
std::stringstream ss1, ss2;
62-
63-
ss1 << 1234;
64-
ss2 << source;
65-
66-
sink(ss1);
67-
sink(ss2); // tainted [NOT DETECTED]
68-
sink(ss1.str());
69-
sink(ss2.str()); // tainted [NOT DETECTED]
70-
}
71-
7235
void test_strings2()
7336
{
7437
string path1 = user_input();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
#include "stl.h"
3+
4+
using namespace std;
5+
6+
char *source();
7+
8+
void sink(const std::string &s) {};
9+
void sink(const std::stringstream &s) {};
10+
11+
void test_stringstream()
12+
{
13+
std::stringstream ss1, ss2, ss3, ss4, ss5;
14+
std::string t(source());
15+
16+
ss1 << "1234";
17+
ss2 << source();
18+
ss3 << "123" << source();
19+
ss4 << source() << "456";
20+
ss5 << t;
21+
22+
sink(ss1);
23+
sink(ss2); // tainted [NOT DETECTED]
24+
sink(ss3); // tainted [NOT DETECTED]
25+
sink(ss4); // tainted [NOT DETECTED]
26+
sink(ss5); // tainted [NOT DETECTED]
27+
sink(ss1.str());
28+
sink(ss2.str()); // tainted [NOT DETECTED]
29+
sink(ss3.str()); // tainted [NOT DETECTED]
30+
sink(ss4.str()); // tainted [NOT DETECTED]
31+
sink(ss5.str()); // tainted [NOT DETECTED]
32+
}
33+
34+
void test_stringstream_int(int source)
35+
{
36+
std::stringstream ss1, ss2;
37+
38+
ss1 << 1234;
39+
ss2 << source;
40+
41+
sink(ss1);
42+
sink(ss2); // tainted [NOT DETECTED]
43+
sink(ss1.str());
44+
sink(ss2.str()); // tainted [NOT DETECTED]
45+
}

cpp/ql/test/library-tests/dataflow/taint-tests/taint.expected

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,34 @@
3232
| movableclass.cpp:55:8:55:9 | s2 | movableclass.cpp:52:23:52:28 | call to source |
3333
| movableclass.cpp:64:8:64:9 | s2 | movableclass.cpp:23:55:23:60 | call to source |
3434
| movableclass.cpp:65:11:65:11 | call to operator= | movableclass.cpp:65:13:65:18 | call to source |
35-
| string.cpp:29:7:29:7 | a | string.cpp:25:12:25:17 | call to source |
36-
| string.cpp:31:7:31:7 | c | string.cpp:27:16:27:21 | call to source |
37-
| string.cpp:33:9:33:13 | call to c_str | string.cpp:27:16:27:21 | call to source |
38-
| string.cpp:75:13:75:17 | call to c_str | string.cpp:14:10:14:15 | call to source |
39-
| string.cpp:79:13:79:17 | call to c_str | string.cpp:14:10:14:15 | call to source |
40-
| string.cpp:82:13:82:17 | call to c_str | string.cpp:14:10:14:15 | call to source |
41-
| string.cpp:92:7:92:8 | cs | string.cpp:87:19:87:24 | call to source |
42-
| string.cpp:93:7:93:8 | ss | string.cpp:87:19:87:24 | call to source |
43-
| string.cpp:106:7:106:8 | cs | string.cpp:98:19:98:24 | call to source |
44-
| string.cpp:107:7:107:8 | ss | string.cpp:98:19:98:24 | call to source |
45-
| string.cpp:129:8:129:9 | s1 | string.cpp:124:18:124:23 | call to source |
46-
| string.cpp:130:8:130:9 | s2 | string.cpp:125:20:125:25 | call to source |
47-
| string.cpp:131:8:131:9 | s3 | string.cpp:127:8:127:13 | call to source |
48-
| string.cpp:150:8:150:9 | s1 | string.cpp:146:32:146:37 | call to source |
49-
| string.cpp:151:8:151:9 | s2 | string.cpp:148:20:148:25 | call to source |
50-
| string.cpp:158:8:158:8 | c | string.cpp:156:16:156:21 | call to source |
51-
| string.cpp:166:8:166:8 | c | string.cpp:156:16:156:21 | call to source |
52-
| string.cpp:171:8:171:8 | c | string.cpp:169:28:169:33 | call to source |
53-
| string.cpp:181:11:181:11 | call to operator+ | string.cpp:178:18:178:23 | call to source |
54-
| string.cpp:182:11:182:11 | call to operator+ | string.cpp:178:18:178:23 | call to source |
55-
| string.cpp:183:11:183:11 | call to operator+ | string.cpp:178:18:178:23 | call to source |
56-
| string.cpp:186:11:186:11 | call to operator+ | string.cpp:186:13:186:18 | call to source |
57-
| string.cpp:195:8:195:9 | s5 | string.cpp:191:18:191:23 | call to source |
58-
| string.cpp:199:8:199:9 | s6 | string.cpp:191:18:191:23 | call to source |
59-
| string.cpp:204:8:204:9 | s7 | string.cpp:202:9:202:14 | call to source |
60-
| string.cpp:208:8:208:9 | s8 | string.cpp:191:18:191:23 | call to source |
61-
| string.cpp:213:8:213:9 | s9 | string.cpp:211:13:211:18 | call to source |
62-
| string.cpp:221:8:221:10 | s10 | string.cpp:218:12:218:26 | call to source |
35+
| string.cpp:28:7:28:7 | a | string.cpp:24:12:24:17 | call to source |
36+
| string.cpp:30:7:30:7 | c | string.cpp:26:16:26:21 | call to source |
37+
| string.cpp:32:9:32:13 | call to c_str | string.cpp:26:16:26:21 | call to source |
38+
| string.cpp:38:13:38:17 | call to c_str | string.cpp:14:10:14:15 | call to source |
39+
| string.cpp:42:13:42:17 | call to c_str | string.cpp:14:10:14:15 | call to source |
40+
| string.cpp:45:13:45:17 | call to c_str | string.cpp:14:10:14:15 | call to source |
41+
| string.cpp:55:7:55:8 | cs | string.cpp:50:19:50:24 | call to source |
42+
| string.cpp:56:7:56:8 | ss | string.cpp:50:19:50:24 | call to source |
43+
| string.cpp:69:7:69:8 | cs | string.cpp:61:19:61:24 | call to source |
44+
| string.cpp:70:7:70:8 | ss | string.cpp:61:19:61:24 | call to source |
45+
| string.cpp:92:8:92:9 | s1 | string.cpp:87:18:87:23 | call to source |
46+
| string.cpp:93:8:93:9 | s2 | string.cpp:88:20:88:25 | call to source |
47+
| string.cpp:94:8:94:9 | s3 | string.cpp:90:8:90:13 | call to source |
48+
| string.cpp:113:8:113:9 | s1 | string.cpp:109:32:109:37 | call to source |
49+
| string.cpp:114:8:114:9 | s2 | string.cpp:111:20:111:25 | call to source |
50+
| string.cpp:121:8:121:8 | c | string.cpp:119:16:119:21 | call to source |
51+
| string.cpp:129:8:129:8 | c | string.cpp:119:16:119:21 | call to source |
52+
| string.cpp:134:8:134:8 | c | string.cpp:132:28:132:33 | call to source |
53+
| string.cpp:144:11:144:11 | call to operator+ | string.cpp:141:18:141:23 | call to source |
54+
| string.cpp:145:11:145:11 | call to operator+ | string.cpp:141:18:141:23 | call to source |
55+
| string.cpp:146:11:146:11 | call to operator+ | string.cpp:141:18:141:23 | call to source |
56+
| string.cpp:149:11:149:11 | call to operator+ | string.cpp:149:13:149:18 | call to source |
57+
| string.cpp:158:8:158:9 | s5 | string.cpp:154:18:154:23 | call to source |
58+
| string.cpp:162:8:162:9 | s6 | string.cpp:154:18:154:23 | call to source |
59+
| string.cpp:167:8:167:9 | s7 | string.cpp:165:9:165:14 | call to source |
60+
| string.cpp:171:8:171:9 | s8 | string.cpp:154:18:154:23 | call to source |
61+
| string.cpp:176:8:176:9 | s9 | string.cpp:174:13:174:18 | call to source |
62+
| string.cpp:184:8:184:10 | s10 | string.cpp:181:12:181:26 | call to source |
6363
| structlikeclass.cpp:35:8:35:9 | s1 | structlikeclass.cpp:29:22:29:27 | call to source |
6464
| structlikeclass.cpp:36:8:36:9 | s2 | structlikeclass.cpp:30:24:30:29 | call to source |
6565
| structlikeclass.cpp:37:8:37:9 | s3 | structlikeclass.cpp:29:22:29:27 | call to source |

cpp/ql/test/library-tests/dataflow/taint-tests/test_diff.expected

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@
3030
| movableclass.cpp:55:8:55:9 | movableclass.cpp:52:23:52:28 | AST only |
3131
| movableclass.cpp:64:8:64:9 | movableclass.cpp:23:55:23:60 | AST only |
3232
| movableclass.cpp:65:11:65:11 | movableclass.cpp:65:13:65:18 | AST only |
33-
| string.cpp:31:7:31:7 | string.cpp:27:16:27:21 | AST only |
34-
| string.cpp:33:9:33:13 | string.cpp:27:16:27:21 | AST only |
35-
| string.cpp:75:13:75:17 | string.cpp:14:10:14:15 | AST only |
36-
| string.cpp:79:13:79:17 | string.cpp:14:10:14:15 | AST only |
37-
| string.cpp:82:13:82:17 | string.cpp:14:10:14:15 | AST only |
38-
| string.cpp:92:7:92:8 | string.cpp:87:19:87:26 | IR only |
39-
| string.cpp:93:7:93:8 | string.cpp:87:19:87:24 | AST only |
40-
| string.cpp:106:7:106:8 | string.cpp:98:19:98:24 | AST only |
41-
| string.cpp:107:7:107:8 | string.cpp:98:19:98:24 | AST only |
42-
| string.cpp:129:8:129:9 | string.cpp:124:18:124:23 | AST only |
43-
| string.cpp:130:8:130:9 | string.cpp:125:20:125:25 | AST only |
44-
| string.cpp:131:8:131:9 | string.cpp:127:8:127:13 | AST only |
45-
| string.cpp:150:8:150:9 | string.cpp:146:32:146:37 | AST only |
46-
| string.cpp:151:8:151:9 | string.cpp:148:20:148:25 | AST only |
47-
| string.cpp:158:8:158:8 | string.cpp:156:16:156:21 | AST only |
48-
| string.cpp:166:8:166:8 | string.cpp:156:16:156:21 | AST only |
49-
| string.cpp:171:8:171:8 | string.cpp:169:28:169:33 | AST only |
50-
| string.cpp:181:11:181:11 | string.cpp:178:18:178:23 | AST only |
51-
| string.cpp:182:11:182:11 | string.cpp:178:18:178:23 | AST only |
52-
| string.cpp:183:11:183:11 | string.cpp:178:18:178:23 | AST only |
53-
| string.cpp:186:11:186:11 | string.cpp:186:13:186:18 | AST only |
54-
| string.cpp:195:8:195:9 | string.cpp:191:18:191:23 | AST only |
55-
| string.cpp:199:8:199:9 | string.cpp:191:18:191:23 | AST only |
56-
| string.cpp:204:8:204:9 | string.cpp:202:9:202:14 | AST only |
57-
| string.cpp:208:8:208:9 | string.cpp:191:18:191:23 | AST only |
58-
| string.cpp:213:8:213:9 | string.cpp:211:13:211:18 | AST only |
59-
| string.cpp:221:8:221:10 | string.cpp:218:12:218:26 | AST only |
33+
| string.cpp:30:7:30:7 | string.cpp:26:16:26:21 | AST only |
34+
| string.cpp:32:9:32:13 | string.cpp:26:16:26:21 | AST only |
35+
| string.cpp:38:13:38:17 | string.cpp:14:10:14:15 | AST only |
36+
| string.cpp:42:13:42:17 | string.cpp:14:10:14:15 | AST only |
37+
| string.cpp:45:13:45:17 | string.cpp:14:10:14:15 | AST only |
38+
| string.cpp:55:7:55:8 | string.cpp:50:19:50:26 | IR only |
39+
| string.cpp:56:7:56:8 | string.cpp:50:19:50:24 | AST only |
40+
| string.cpp:69:7:69:8 | string.cpp:61:19:61:24 | AST only |
41+
| string.cpp:70:7:70:8 | string.cpp:61:19:61:24 | AST only |
42+
| string.cpp:92:8:92:9 | string.cpp:87:18:87:23 | AST only |
43+
| string.cpp:93:8:93:9 | string.cpp:88:20:88:25 | AST only |
44+
| string.cpp:94:8:94:9 | string.cpp:90:8:90:13 | AST only |
45+
| string.cpp:113:8:113:9 | string.cpp:109:32:109:37 | AST only |
46+
| string.cpp:114:8:114:9 | string.cpp:111:20:111:25 | AST only |
47+
| string.cpp:121:8:121:8 | string.cpp:119:16:119:21 | AST only |
48+
| string.cpp:129:8:129:8 | string.cpp:119:16:119:21 | AST only |
49+
| string.cpp:134:8:134:8 | string.cpp:132:28:132:33 | AST only |
50+
| string.cpp:144:11:144:11 | string.cpp:141:18:141:23 | AST only |
51+
| string.cpp:145:11:145:11 | string.cpp:141:18:141:23 | AST only |
52+
| string.cpp:146:11:146:11 | string.cpp:141:18:141:23 | AST only |
53+
| string.cpp:149:11:149:11 | string.cpp:149:13:149:18 | AST only |
54+
| string.cpp:158:8:158:9 | string.cpp:154:18:154:23 | AST only |
55+
| string.cpp:162:8:162:9 | string.cpp:154:18:154:23 | AST only |
56+
| string.cpp:167:8:167:9 | string.cpp:165:9:165:14 | AST only |
57+
| string.cpp:171:8:171:9 | string.cpp:154:18:154:23 | AST only |
58+
| string.cpp:176:8:176:9 | string.cpp:174:13:174:18 | AST only |
59+
| string.cpp:184:8:184:10 | string.cpp:181:12:181:26 | AST only |
6060
| structlikeclass.cpp:35:8:35:9 | structlikeclass.cpp:29:22:29:27 | AST only |
6161
| structlikeclass.cpp:36:8:36:9 | structlikeclass.cpp:30:24:30:29 | AST only |
6262
| structlikeclass.cpp:37:8:37:9 | structlikeclass.cpp:29:22:29:27 | AST only |

cpp/ql/test/library-tests/dataflow/taint-tests/test_ir.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
| format.cpp:157:7:157:22 | (int)... | format.cpp:147:12:147:25 | call to source |
22
| format.cpp:157:7:157:22 | access to array | format.cpp:147:12:147:25 | call to source |
33
| format.cpp:158:7:158:27 | ... + ... | format.cpp:148:16:148:30 | call to source |
4-
| string.cpp:29:7:29:7 | (const char *)... | string.cpp:25:12:25:17 | call to source |
5-
| string.cpp:29:7:29:7 | a | string.cpp:25:12:25:17 | call to source |
6-
| string.cpp:92:7:92:8 | cs | string.cpp:87:19:87:24 | call to source |
7-
| string.cpp:92:7:92:8 | cs | string.cpp:87:19:87:26 | (const char *)... |
4+
| string.cpp:28:7:28:7 | (const char *)... | string.cpp:24:12:24:17 | call to source |
5+
| string.cpp:28:7:28:7 | a | string.cpp:24:12:24:17 | call to source |
6+
| string.cpp:55:7:55:8 | cs | string.cpp:50:19:50:24 | call to source |
7+
| string.cpp:55:7:55:8 | cs | string.cpp:50:19:50:26 | (const char *)... |
88
| structlikeclass.cpp:38:8:38:9 | s4 | structlikeclass.cpp:33:8:33:13 | call to source |
99
| structlikeclass.cpp:61:8:61:9 | s2 | structlikeclass.cpp:58:24:58:29 | call to source |
1010
| structlikeclass.cpp:62:8:62:20 | ... = ... | structlikeclass.cpp:62:13:62:18 | call to source |

0 commit comments

Comments
 (0)