# Issue with safe mode check in tempnam()

- Thread: https://externals.io/message/46972
- Original archive: https://news-web.php.net/php.internals/46972
- Started by Martin Jansen on 2010-02-09T20:13:00+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #46972 — Martin Jansen — 2010-02-09T20:13:00+00:00

URL: https://externals.io/message/46972#46972

Recently we've experienced an issue regarding the safe mode check in
 `tempnam()` which was introduced in r288945 4 months ago.  When calling
tempnam("/tmp/foo"), with /tmp/foo being a directory, it turned out that
the safe mode UID check was performed on /tmp instead of /tmp/foo. When
calling tempnam("/tmp/foo/"), everything worked as expected.  Changing
the mode parameter for the php_checkuid call from
CHECKUID_ALLOW_ONLY_DIR to CHECKUID_CHECK_FILE_AND_DIR fixes this issue.

A patch for PHP_5_2 is attached.  Is the chosen approach correct?  I
have been unable to come up with a fitting unit test because I could not
figure out how to create the necessary directory scaffolding in e.g.
/tmp with safe_mode=1 already being set in the --INI-- section of the test.

- Martin
