Skip to content

Commit

Permalink
C++: Add tests for a few string-related classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasVP committed Dec 10, 2024
1 parent c5bb907 commit 64464b3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cpp/ql/test/library-tests/dataflow/taint-tests/atl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,3 +1210,33 @@ void test_CStringT() {
sink(s1.TrimRight("abc").GetString()); // $ ir
sink(s1.TrimRight().GetString()); // $ ir
}

struct CStringData {
void* data() throw();
};

void test_CStringData() {
CStringData d = source<CStringData>();
sink(d.data()); // $ MISSING: ir
}

template<typename TCharType>
struct CStrBufT {
typedef CSimpleStringT<TCharType> StringType;

using PCXSTR = typename StringType::PCXSTR;
using PXSTR = typename StringType::PXSTR;

CStrBufT(StringType& str, int nMinLength, DWORD dwFlags);
CStrBufT(StringType& str);

operator PCXSTR() const throw();
operator PXSTR() throw();
};

void test_CStrBufT() {
CStringT<char> s = source<CStringT<char>>();
CStrBufT<char> b(s, 42, 0);
sink(static_cast<CStrBufT<char>::PCXSTR>(b)); // $ MISSING: ir
sink(static_cast<CStrBufT<char>::PXSTR>(b)); // $ MISSING: ir
}
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,13 @@ WARNING: module 'TaintTracking' has been deprecated and may be removed in future
| atl.cpp:1210:8:1210:9 | ref arg s1 | atl.cpp:1211:8:1211:9 | s1 | |
| atl.cpp:1210:8:1210:9 | ref arg s1 | atl.cpp:1212:1:1212:1 | s1 | |
| atl.cpp:1211:8:1211:9 | ref arg s1 | atl.cpp:1212:1:1212:1 | s1 | |
| atl.cpp:1219:19:1219:37 | call to source | atl.cpp:1220:8:1220:8 | d | |
| atl.cpp:1238:22:1238:43 | call to source | atl.cpp:1239:20:1239:20 | s | |
| atl.cpp:1238:22:1238:43 | call to source | atl.cpp:1242:1:1242:1 | s | |
| atl.cpp:1239:20:1239:20 | ref arg s | atl.cpp:1242:1:1242:1 | s | |
| atl.cpp:1239:20:1239:28 | call to CStrBufT | atl.cpp:1240:44:1240:44 | b | |
| atl.cpp:1239:20:1239:28 | call to CStrBufT | atl.cpp:1241:43:1241:43 | b | |
| atl.cpp:1240:44:1240:44 | ref arg b | atl.cpp:1241:43:1241:43 | b | |
| bsd.cpp:17:11:17:16 | call to source | bsd.cpp:20:18:20:18 | s | |
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:20:22:20:25 | addr | |
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:23:8:23:11 | addr | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,11 @@ getParameterTypeName
| atl.cpp:1091:13:1091:20 | TrimLeft | 0 | PCXSTR |
| atl.cpp:1093:13:1093:21 | TrimRight | 0 | XCHAR |
| atl.cpp:1094:13:1094:21 | TrimRight | 0 | PCXSTR |
| atl.cpp:1214:8:1214:8 | operator= | 0 | CStringData && |
| atl.cpp:1214:8:1214:8 | operator= | 0 | const CStringData & |
| atl.cpp:1230:3:1230:10 | CStrBufT | 0 | StringType & |
| atl.cpp:1230:3:1230:10 | CStrBufT | 1 | int |
| atl.cpp:1230:3:1230:10 | CStrBufT | 2 | DWORD |
| bsd.cpp:6:8:6:8 | operator= | 0 | const sockaddr & |
| bsd.cpp:6:8:6:8 | operator= | 0 | sockaddr && |
| bsd.cpp:12:5:12:10 | accept | 0 | int |
Expand Down

0 comments on commit 64464b3

Please sign in to comment.