Skip to content

tpm2_send: Avoid unintended stdio closing in close_file()#3550

Merged
JuergenReppSIT merged 1 commit into
tpm2-software:masterfrom
hyperfinitism:fix/avoid-closing-stdio
Feb 18, 2026
Merged

tpm2_send: Avoid unintended stdio closing in close_file()#3550
JuergenReppSIT merged 1 commit into
tpm2-software:masterfrom
hyperfinitism:fix/avoid-closing-stdio

Conversation

@hyperfinitism
Copy link
Copy Markdown
Contributor

The close_file() function currently closes an input FILE f when f && (f != stdin || f != stdout) is true.

This condition is flawed: it is logically equivalent to f && !(f == stdin && f == stdout). The clause !(f == stdin && f == stdout) is always true, the whole condition becomes f (f != nullptr). As a result, the close_file() function may close standard streams (stdin/stdout) unintentionally.

The intended behavior is to close only non-standard file streams. This PR fixes the condition accordingly so that stdin and stdout are never closed by close_file().

Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
@JuergenReppSIT JuergenReppSIT merged commit 56a05ff into tpm2-software:master Feb 18, 2026
23 checks passed
@hyperfinitism hyperfinitism deleted the fix/avoid-closing-stdio branch February 25, 2026 15:27
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