Skip to content

Commit abe9258

Browse files
committed
C++: Add strcpy test for cpp/non-constant-format
1 parent 83afc2a commit abe9258

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
| test.cpp:93:12:93:18 | ++ ... | The format string argument to printf should be constant to prevent security issues and other potential errors. |
2020
| test.cpp:110:12:110:24 | new[] | The format string argument to printf should be constant to prevent security issues and other potential errors. |
2121
| 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. |
22+
| test.cpp:157:12:157:15 | data | The format string argument to printf should be constant to prevent security issues and other potential errors. |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,8 @@ void print_ith_message() {
151151
set_value_of(&i);
152152
printf(messages[i], 1U); // GOOD
153153
}
154+
155+
void fmt_via_strcpy(char *data) {
156+
strcpy(data, "some string");
157+
printf(data);
158+
}

0 commit comments

Comments
 (0)