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

Skip to content

Commit 098b654

Browse files
committed
[CPP-370] Rewrite of NonConstantFormat.ql using the taint tracking library.
1 parent 91902e5 commit 098b654

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

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

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

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

2428
const char *make_message(unsigned int n) {
2529
static char buf[64];
26-
sprintf(buf, "%d tasks left\n", n); // ok
30+
sprintf(buf, "%d tasks left\n", n); // OK
2731
return buf;
2832
}
2933

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

4347
int main(int argc, char **argv) {
4448
const char *message = messages[2];
49+
printf(simple_func("Hello, World\n")); // OK
4550
printf(choose_message(argc - 1), argc - 1); // OK
4651
printf(messages[1]); // OK
4752
printf(message); // OK
48-
printf(make_message(argc - 1)); // NOT OK
53+
printf(make_message(argc - 1)); // OK
4954
printf("Hello, World\n"); // OK
55+
printf(gettext("Hello, World\n")); // OK
5056
printf(_("Hello, World\n")); // OK
5157
{
5258
char hello[] = "hello, World\n";

0 commit comments

Comments
 (0)