Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92054e2

Browse files
committed
[CPP-370] Reformat test cases so that the .expect files line up with what was
checked in initially. Check for DataFlow::DefinitionByReferenceNode when computing isSource() for our taint analysis.
1 parent 098b654 commit 92054e2

2 files changed

Lines changed: 2 additions & 12 deletions

File tree

cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ const char *messages[] = {
1010
"%u tasks left\n",
1111
};
1212

13-
const char *simple_func(const char *str) {
14-
return str;
15-
}
16-
1713
const char *choose_message(unsigned int n) {
1814
if (n == 0) {
1915
const char *message = messages[0];
@@ -27,7 +23,7 @@ const char *choose_message(unsigned int n) {
2723

2824
const char *make_message(unsigned int n) {
2925
static char buf[64];
30-
sprintf(buf, "%d tasks left\n", n); // OK
26+
sprintf(buf, "%d tasks left\n", n); // ok
3127
return buf;
3228
}
3329

@@ -46,13 +42,11 @@ const char *const_wash(char *str) {
4642

4743
int main(int argc, char **argv) {
4844
const char *message = messages[2];
49-
printf(simple_func("Hello, World\n")); // OK
5045
printf(choose_message(argc - 1), argc - 1); // OK
5146
printf(messages[1]); // OK
5247
printf(message); // OK
53-
printf(make_message(argc - 1)); // OK
48+
printf(make_message(argc - 1)); // NOT OK
5449
printf("Hello, World\n"); // OK
55-
printf(gettext("Hello, World\n")); // OK
5650
printf(_("Hello, World\n")); // OK
5751
{
5852
char hello[] = "hello, World\n";
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
| consts.cpp:81:9:81:10 | c8 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
2-
| consts.cpp:86:9:86:10 | v1 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
32
| consts.cpp:91:9:91:10 | v2 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
4-
| consts.cpp:95:9:95:10 | v3 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
5-
| consts.cpp:100:9:100:10 | v4 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
63
| consts.cpp:103:9:103:15 | call to varFunc | The format string argument to printf should be constant to prevent security issues and other potential errors. |
74
| consts.cpp:107:9:107:10 | v5 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
85
| consts.cpp:112:9:112:10 | v6 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
96
| consts.cpp:116:9:116:13 | access to array | The format string argument to printf should be constant to prevent security issues and other potential errors. |
107
| consts.cpp:121:9:121:10 | v8 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
11-
| consts.cpp:130:9:130:10 | v9 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
128
| consts.cpp:135:9:135:11 | v10 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
139
| consts.cpp:140:9:140:11 | v11 | The format string argument to printf should be constant to prevent security issues and other potential errors. |
1410
| consts.cpp:145:9:145:11 | v12 | The format string argument to printf should be constant to prevent security issues and other potential errors. |

0 commit comments

Comments
 (0)