mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
CPP: Add a taint flow test of 'std::swap'.
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user