Skip to content

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

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/file-close
Closed

file: init fd to -1 to prevent close fd 0 on early failure#21029
bagder wants to merge 1 commit intomasterfrom
bagder/file-close

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Mar 20, 2026

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
Copy link
Copy Markdown

Copilot AI left a comment

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
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