mirror of
https://github.com/github/codeql.git
synced 2026-04-22 23:35:14 +02:00
C++: Add a 'cpp/unsafe-strncat' FP.
This commit is contained in:
@@ -3,3 +3,5 @@
|
||||
| test.c:67:3:67:9 | call to strncat | Potentially unsafe call to strncat. |
|
||||
| test.c:75:3:75:9 | call to strncat | Potentially unsafe call to strncat. |
|
||||
| test.c:76:3:76:9 | call to strncat | Potentially unsafe call to strncat. |
|
||||
| test.c:91:3:91:9 | call to strncat | Potentially unsafe call to strncat. |
|
||||
| test.c:99:3:99:9 | call to strncat | Potentially unsafe call to strncat. |
|
||||
|
||||
@@ -82,3 +82,20 @@ void strncat_test5(char *s) {
|
||||
strncat(buf, s, len - strlen(buf) - 1); // GOOD
|
||||
strncat(buf, s, len - strlen(buf)); // GOOD
|
||||
}
|
||||
|
||||
void strncat_test6() {
|
||||
{
|
||||
char dest[60];
|
||||
dest[0] = '\0';
|
||||
// Will write `dest[0 .. 5]`
|
||||
strncat(dest, "small", sizeof(dest)); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
{
|
||||
char dest[60];
|
||||
memset(dest, 'a', sizeof(dest));
|
||||
dest[54] = '\0';
|
||||
// Will write `dest[54 .. 59]`
|
||||
strncat(dest, "small", sizeof(dest)); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user