Skip to content

stdio: implement tmpnam() and tempnam() functions#478

Draft
julianuziemblo wants to merge 2 commits into
masterfrom
julianuziemblo/RTOS-1333
Draft

stdio: implement tmpnam() and tempnam() functions#478
julianuziemblo wants to merge 2 commits into
masterfrom
julianuziemblo/RTOS-1333

Conversation

@julianuziemblo
Copy link
Copy Markdown
Contributor

@julianuziemblo julianuziemblo commented May 22, 2026

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the tmpnam and tempnam functions, moving the implementation to stdlib/mktemp.c and updating include/stdio.h with the required macro and prototype. The review identified several critical issues: a buffer overflow in tempnam when the prefix is null, broken retry logic in both functions because the template string is modified in place, a memory leak in tempnam when it fails to generate a name, and a lack of POSIX-compliant checks for the TMPDIR environment variable.

Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c Outdated
Comment thread stdlib/mktemp.c
@julianuziemblo julianuziemblo changed the title Julianuziemblo/rtos 1333 stdio: implement tmpnam() and tempnam() functions May 22, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

Unit Test Results

10 590 tests   9 910 ✅  57m 13s ⏱️
   659 suites    670 💤
     1 files       10 ❌

For more details on these failures, see this check.

Results for commit b3e65de.

♻️ This comment has been updated with latest results.

@julianuziemblo
Copy link
Copy Markdown
Contributor Author

Drafting for now as added tests depend on tmpfile() tests, which depend on tmpfile() fixes. Will undraft after phoenix-rtos/phoenix-rtos-posixsrv#32 is merged.

@julianuziemblo julianuziemblo marked this pull request as draft May 22, 2026 13:59
@nalajcie
Copy link
Copy Markdown
Member

if you would use the same branch name for related changes across all submodules, these changes would compile and test succesfully.

PLEASE always use the same branch name on related changes OR use Depends-On: in PR description (as described in https://youtrack.phoenix-rtos.com/articles/CI-A-23070284/Github)

@julianuziemblo
Copy link
Copy Markdown
Contributor Author

if you would use the same branch name for related changes across all submodules, these changes would compile and test succesfully.

it's not this here: as I wrote, I'm fixing tmpfile() in another branch and wanted to base tests for this PR on that branch for now as it adds "posixsrv" directory to tests, which I didn't want to duplicate across PRs. I'll undraft, rerun tests and add reviewers once that PR is merged.

YT: RTOS-1333
@julianuziemblo julianuziemblo force-pushed the julianuziemblo/RTOS-1333 branch from 472358f to b3e65de Compare May 26, 2026 08:35
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.

2 participants