Skip to content

Commit 0e8064d

Browse files
committed
C++: Add a test demonstrating taint.
1 parent ee7ccd7 commit 0e8064d

File tree

1 file changed

+13
-0
lines changed
  • cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests

1 file changed

+13
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/test3.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,16 @@ void test_interprocedural(const char *password1)
140140
send(val(), data, strlen(data), val()); // BAD: `global_password` is sent plaintext
141141
}
142142
}
143+
144+
char *strncpy(char *s1, const char *s2, size_t n);
145+
146+
void test_taint(const char *password)
147+
{
148+
{
149+
char buffer[16];
150+
151+
strncpy(buffer, password, 16);
152+
buffer[15] = 0;
153+
send(val(), buffer, 16, val()); // BAD: `password` is (partially) sent plaintext [NOT DETECTED]
154+
}
155+
}

0 commit comments

Comments
 (0)