mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++: Add test cases.
This commit is contained in:
@@ -18,3 +18,4 @@
|
||||
| test.cpp:87:12:87:16 | hello | The format string argument to printf should be constant to prevent security issues and other potential errors. |
|
||||
| test.cpp:92:12:92:18 | ++ ... | The format string argument to printf should be constant to prevent security issues and other potential errors. |
|
||||
| test.cpp:109:12:109:24 | new[] | The format string argument to printf should be constant to prevent security issues and other potential errors. |
|
||||
| test.cpp:129:20:129:26 | access to array | The format string argument to sprintf should be constant to prevent security issues and other potential errors. |
|
||||
|
||||
@@ -2,7 +2,7 @@ extern "C" int printf(const char *fmt, ...);
|
||||
extern "C" int sprintf(char *buf, const char *fmt, ...);
|
||||
extern "C" char *gettext (const char *);
|
||||
|
||||
|
||||
#define MYSPRINTF sprintf
|
||||
|
||||
bool gettext_debug = false;
|
||||
|
||||
@@ -122,12 +122,12 @@ int main(int argc, char **argv) {
|
||||
//
|
||||
printf(const_wash("Hello, World\n")); // GOOD
|
||||
|
||||
{
|
||||
char buffer[1024];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MYSPRINTF(buffer, "constant"); // GOOD
|
||||
MYSPRINTF(buffer, argv[0]); // BAD
|
||||
}
|
||||
}
|
||||
|
||||
const char *simple_func(const char *str) {
|
||||
|
||||
Reference in New Issue
Block a user