Skip to content

file: init fd to -1 to prevent close fd 0 on early failure - #21029

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/file-close
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/file-close

Conversation

@bagder

@bagder bagder commented Mar 20, 2026

Copy link
Copy Markdown
Member

Spotted by Codex Security

@bagder
bagder marked this pull request as ready for review March 20, 2026 12:40
@bagder
bagder requested a review from Copilot March 20, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the FILE protocol’s per-easy metadata initialization to avoid accidentally closing file descriptor 0 (stdin) when an early failure triggers cleanup.

Changes:

  • Initialize struct FILEPROTO::fd to -1 immediately after allocation so cleanup won’t close an unintended FD on error paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder closed this in 0b182ae Mar 20, 2026
@bagder
bagder deleted the bagder/file-close branch March 20, 2026 14:00
dkarpov1970 pushed a commit to dkarpov1970/curl that referenced this pull request Mar 25, 2026
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants