Fix security warning generated by std::tmpnam #106027

Merged
Sergey Sharybin merged 3 commits from Sergey/blender:tempfile into main 2023-03-24 14:52:55 +01:00

3 Commits

Author SHA1 Message Date
Sergey Sharybin 51c1510893 Fix security warning generated by std::tmpnam
buildbot/vexp-code-patch-coordinator Build done. Details
Effectively replicate the behavior of the function in the manner
which is used for autosave file.

There might be better a solution which is cross-platform and does
not suffer from the time of check, time of use (TOCTOU) vector of
attack. This seems to be a bigger project to figure out, so until
then silence the warning: it is fine since the directory is only
used to chdir to, so worst case an external attacker can introduce
is a test failure.
2023-03-23 12:42:03 +01:00
Sergey Sharybin bc02fe46ff Refactor: Use utility function from BLI for temp directory
Should be no functional changes as the utility is based on the
code from the where_is_temp().
2023-03-23 12:39:10 +01:00
Sergey Sharybin 64e8e7082d BLI: Add utility to access system-wide temporary directory
It provides path to a directory suitable for storing temporary files
which satisfies the following conditions:

- The directory exists.
- The return path has trailing directory separator.

It is based on the code used in the appdir.c to get the temporary
directory.

For the C++ people: this is similar to the temp_directory_path()
from the std::filesystem.

No functional changes expected as it is a new code which is planned
to be used on other places as a followup development.
2023-03-23 12:39:10 +01:00