Skip to content

Commit 64464b3

Browse files
committed
C++: Add tests for a few string-related classes.
1 parent c5bb907 commit 64464b3

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,3 +1210,33 @@ void test_CStringT() {
12101210
sink(s1.TrimRight("abc").GetString()); // $ ir
12111211
sink(s1.TrimRight().GetString()); // $ ir
12121212
}
1213+
1214+
struct CStringData {
1215+
void* data() throw();
1216+
};
1217+
1218+
void test_CStringData() {
1219+
CStringData d = source<CStringData>();
1220+
sink(d.data()); // $ MISSING: ir
1221+
}
1222+
1223+
template<typename TCharType>
1224+
struct CStrBufT {
1225+
typedef CSimpleStringT<TCharType> StringType;
1226+
1227+
using PCXSTR = typename StringType::PCXSTR;
1228+
using PXSTR = typename StringType::PXSTR;
1229+
1230+
CStrBufT(StringType& str, int nMinLength, DWORD dwFlags);
1231+
CStrBufT(StringType& str);
1232+
1233+
operator PCXSTR() const throw();
1234+
operator PXSTR() throw();
1235+
};
1236+
1237+
void test_CStrBufT() {
1238+
CStringT<char> s = source<CStringT<char>>();
1239+
CStrBufT<char> b(s, 42, 0);
1240+
sink(static_cast<CStrBufT<char>::PCXSTR>(b)); // $ MISSING: ir
1241+
sink(static_cast<CStrBufT<char>::PXSTR>(b)); // $ MISSING: ir
1242+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,13 @@ WARNING: module 'TaintTracking' has been deprecated and may be removed in future
12931293
| atl.cpp:1210:8:1210:9 | ref arg s1 | atl.cpp:1211:8:1211:9 | s1 | |
12941294
| atl.cpp:1210:8:1210:9 | ref arg s1 | atl.cpp:1212:1:1212:1 | s1 | |
12951295
| atl.cpp:1211:8:1211:9 | ref arg s1 | atl.cpp:1212:1:1212:1 | s1 | |
1296+
| atl.cpp:1219:19:1219:37 | call to source | atl.cpp:1220:8:1220:8 | d | |
1297+
| atl.cpp:1238:22:1238:43 | call to source | atl.cpp:1239:20:1239:20 | s | |
1298+
| atl.cpp:1238:22:1238:43 | call to source | atl.cpp:1242:1:1242:1 | s | |
1299+
| atl.cpp:1239:20:1239:20 | ref arg s | atl.cpp:1242:1:1242:1 | s | |
1300+
| atl.cpp:1239:20:1239:28 | call to CStrBufT | atl.cpp:1240:44:1240:44 | b | |
1301+
| atl.cpp:1239:20:1239:28 | call to CStrBufT | atl.cpp:1241:43:1241:43 | b | |
1302+
| atl.cpp:1240:44:1240:44 | ref arg b | atl.cpp:1241:43:1241:43 | b | |
12961303
| bsd.cpp:17:11:17:16 | call to source | bsd.cpp:20:18:20:18 | s | |
12971304
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:20:22:20:25 | addr | |
12981305
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:23:8:23:11 | addr | |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,11 @@ getParameterTypeName
11001100
| atl.cpp:1091:13:1091:20 | TrimLeft | 0 | PCXSTR |
11011101
| atl.cpp:1093:13:1093:21 | TrimRight | 0 | XCHAR |
11021102
| atl.cpp:1094:13:1094:21 | TrimRight | 0 | PCXSTR |
1103+
| atl.cpp:1214:8:1214:8 | operator= | 0 | CStringData && |
1104+
| atl.cpp:1214:8:1214:8 | operator= | 0 | const CStringData & |
1105+
| atl.cpp:1230:3:1230:10 | CStrBufT | 0 | StringType & |
1106+
| atl.cpp:1230:3:1230:10 | CStrBufT | 1 | int |
1107+
| atl.cpp:1230:3:1230:10 | CStrBufT | 2 | DWORD |
11031108
| bsd.cpp:6:8:6:8 | operator= | 0 | const sockaddr & |
11041109
| bsd.cpp:6:8:6:8 | operator= | 0 | sockaddr && |
11051110
| bsd.cpp:12:5:12:10 | accept | 0 | int |

0 commit comments

Comments
 (0)