CPP: Add a taint flow test of 'std::swap'.

This commit is contained in:
Geoffrey White
2019-07-12 16:17:52 +01:00
parent a6b7f2d1f6
commit f132bca06e
5 changed files with 37 additions and 0 deletions

View File

@@ -194,3 +194,24 @@ void test_memcpy(int *source) {
memcpy(&x, source, sizeof(int));
sink(x);
}
// --- swap ---
namespace std {
template<class T> constexpr void swap(T& a, T& b);
}
void test_swap() {
int x, y;
x = source();
y = 0;
sink(x); // tainted
sink(y);
std::swap(x, y);
sink(x); // [FALSE POSITIVE]
sink(y); // tainted [NOT DETECTED]
}