Skip to content

Commit 9e50fc6

Browse files
committed
Updating tests to account for removing const char* heuristic.
1 parent caf2ee2 commit 9e50fc6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
| NonConstantFormat.c:30:10:30:16 | access to array | The format string argument to printf should be constant to prevent security issues and other potential errors. |
22
| NonConstantFormat.c:41:9:41:27 | call to any_random_function | The format string argument to printf should be constant to prevent security issues and other potential errors. |
33
| NonConstantFormat.c:45:9:45:48 | call to gettext | The format string argument to printf should be constant to prevent security issues and other potential errors. |
4+
| nested.cpp:21:23:21:26 | fmt0 | The format string argument to snprintf should be constant to prevent security issues and other potential errors. |
5+
| nested.cpp:79:32:79:38 | call to get_fmt | The format string argument to diagnostic should be constant to prevent security issues and other potential errors. |
46
| nested.cpp:87:18:87:20 | fmt | The format string argument to diagnostic should be constant to prevent security issues and other potential errors. |
57
| test.cpp:51:10:51:21 | call to make_message | The format string argument to printf should be constant to prevent security issues and other potential errors. |
68
| test.cpp:130:20:130:26 | access to array | The format string argument to sprintf should be constant to prevent security issues and other potential errors. |

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern "C" int snprintf ( char * s, int n, const char * format, ... );
1818
struct A {
1919
void do_print(const char *fmt0) {
2020
char buf[32];
21-
snprintf(buf, 32, fmt0); // GOOD, all paths to year use const char*
21+
snprintf(buf, 32, fmt0); // BAD, all paths from unknown const char*, not assuming literal
2222
}
2323
};
2424

@@ -34,7 +34,7 @@ struct C {
3434
void do_some_printing(const char *fmt) {
3535
b.do_printing(fmt);
3636
}
37-
const char *ext_fmt_str(void);
37+
const char *ext_fmt_str(void); // NOTE: not assuming result is literal
3838
};
3939

4040
void foo(void) {
@@ -76,7 +76,7 @@ void diagnostic(const char *fmt, ...)
7676
}
7777

7878
void bar(void) {
79-
diagnostic (some_instance->get_fmt()); // GOOD get_fmt is const char* assumed static
79+
diagnostic (some_instance->get_fmt()); // BAD const char* but not assuming literal
8080
}
8181

8282
namespace ns {

0 commit comments

Comments
 (0)