From 1b8f5f08f0c755095d30689905039bd139eb5b7c Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Wed, 24 Aug 2022 18:05:01 +0200 Subject: [PATCH] unittests/ThunkLibs: Fix warning about "dangerous" use of tmpnam tmpnam is considered insecure since it's vulnerable to TOCTOU issues. This is not an issue for these tests, but replacing tmpnam is not any more complicated than silencing the warning. --- unittests/ThunkLibs/generator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unittests/ThunkLibs/generator.cpp b/unittests/ThunkLibs/generator.cpp index ee7c1f41e..9482dc362 100644 --- a/unittests/ThunkLibs/generator.cpp +++ b/unittests/ThunkLibs/generator.cpp @@ -47,7 +47,10 @@ std::ostream& operator<<(std::ostream& os, const SourceWithAST& ast) { struct Fixture { Fixture() { - tmpdir = std::tmpnam(nullptr); + tmpdir = std::string { P_tmpdir } + "/thunkgentestXXXXXX"; + if (!mkdtemp(tmpdir.data())) { + std::abort(); + } std::filesystem::create_directory(tmpdir); output_filenames = { tmpdir + "/function_unpacks",