C++: Add tests for std::string 'operator[]' and 'at()'.

This commit is contained in:
Geoffrey White
2020-08-24 13:43:48 +01:00
parent d56a03389c
commit f6770c5b88
3 changed files with 47 additions and 0 deletions

View File

@@ -321,3 +321,22 @@ void test_string_substr()
sink(a.substr(0, a.length()));
sink(b.substr(0, b.length())); // tainted
}
void test_string_at()
{
std::string a("123");
std::string b("123");
std::string c("123");
sink(a);
sink(b);
sink(c);
a[0] = ns_char::source();
b.at(0) = ns_char::source();
c[0] = a[0];
sink(a); // tainted [NOT DETECTED]
sink(b); // tainted [NOT DETECTED]
sink(c); // tainted [NOT DETECTED]
}