Skip to content

Replace tmpnam with mkstemp/GetTempFileName in temporaryFileName#4795

Draft
AnHeuermann wants to merge 1 commit into
modelica:masterfrom
AnHeuermann:remove-tmpnam
Draft

Replace tmpnam with mkstemp/GetTempFileName in temporaryFileName#4795
AnHeuermann wants to merge 1 commit into
modelica:masterfrom
AnHeuermann:remove-tmpnam

Conversation

@AnHeuermann

Copy link
Copy Markdown
Contributor

Issue

Fixes #4794.

Changes

tmpnam is deprecated and has a dangerous race condition:

  • On POSIX, atomically create the file itself via mkstemp
    • Respect environment variable TMPDIR, fall back to P_tmpdir or /tmp.
  • On Windows, use GetTempPathA/GetTempFileNameA, which also atomically create the file.
  • Update Files.mo documention
    • Function returns the path of a freshly created empty file rather than a name that does not yet exist.
    • Drop the now-obsolete race-condition warning

tmpnam is deprecated and has a dangerous race condition:

* On POSIX, atomically create the file itself via `mkstemp`
  * Respect environment variable `TMPDIR`, fall back to `P_tmpdir` or
    `/tmp`.
* On Windows, use `GetTempPathA`/`GetTempFileNameA`, which also
  atomically create the file.
* Update Files.mo documention
  * Function returns the path of a freshly created empty file rather
    than a name that does not yet exist.
  * Drop the now-obsolete race-condition warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModelicaInternal_temporaryFileName: Replace tmpnam with mkstemp

1 participant