mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
C++: Add a test of unknown format specifiers (with specsAreKnown check disabled).
This commit is contained in:
@@ -921,7 +921,7 @@ class FormatLiteral extends Literal {
|
||||
* format specifiers are present in the format string).
|
||||
*/
|
||||
predicate specsAreKnown() {
|
||||
this.getNumConvSpec() = count(int n | exists(this.getNumArgNeeded(n)))
|
||||
any()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,3 +12,6 @@
|
||||
| test.c:39:3:39:8 | call to printf | Format expects 2 arguments but given 5 |
|
||||
| test.c:40:3:40:8 | call to printf | Format expects 2 arguments but given 4 |
|
||||
| test.c:41:3:41:8 | call to printf | Format expects 2 arguments but given 3 |
|
||||
| test.c:46:2:46:7 | call to printf | Format expects 1 arguments but given 2 |
|
||||
| test.c:47:2:47:7 | call to printf | Format expects 1 arguments but given 2 |
|
||||
| test.c:48:2:48:7 | call to printf | Format expects 1 arguments but given 2 |
|
||||
|
||||
@@ -42,4 +42,8 @@ void test(int i, const char *str)
|
||||
}
|
||||
|
||||
printf("%@ %i %i", 1, 2); // GOOD
|
||||
|
||||
printf("%Y", 1, 2); // GOOD (unknown format character, this might be correct) [FALSE POSITIVE]
|
||||
printf("%1.1Y", 1, 2); // GOOD (unknown format character, this might be correct) [FALSE POSITIVE]
|
||||
printf("%*.*Y", 1, 2); // GOOD (unknown format character, this might be correct) [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user