==== Use a secure API function

Temporary files handling APIs generally provide secure functions to create
temporary files. In most cases, they operate in an atomical way, creating and
opening a file with a unique and unpredictable name in a single call. Those
functions can often be used to replace less secure alternatives without
requiring important development efforts.