From 1e8daff02a77c75b2b84264b3021708d8025368b Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Tue, 22 Aug 2023 16:23:47 +0200 Subject: [PATCH 1/2] C++: Add `cpp/non-constant-format` test --- .../Likely Bugs/Format/NonConstantFormat/test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp b/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp index f42d6835aa7..b864336699d 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp +++ b/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp @@ -156,3 +156,10 @@ void fmt_via_strcpy(char *data) { strcpy(data, "some string"); printf(data); // BAD } + +void fmt_with_assignment() { + const char *x, *y; + + x = y = "a"; + printf(y); +} From 6566b91355df8f09835a7e17e2e4f9c9ff08656f Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Tue, 22 Aug 2023 16:38:46 +0200 Subject: [PATCH 2/2] C++: Add indication that the test result is good --- .../query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp b/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp index b864336699d..1fadbf20e45 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp +++ b/cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp @@ -161,5 +161,5 @@ void fmt_with_assignment() { const char *x, *y; x = y = "a"; - printf(y); + printf(y); // GOOD }