Skip to content

netrc: survive comment-only .netrc file - #22889

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/netrc-no-content
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/netrc-no-content

Conversation

@bagder

@bagder bagder commented Sep 9, 2026

Copy link
Copy Markdown
Member

A .netrc file with only a comment and no newline caused an NULL dereference

Verify with test 2429

Reported-by: Max Dymond

A .netrc file with only a comment and no newlined caused an NULL
dereference

Verify with test 2429

Reported-by: Max Dymond
@github-actions github-actions Bot added the tests label Sep 9, 2026
@bagder
bagder marked this pull request as ready for review September 9, 2026 21:08
@bagder
bagder requested a lite review from Copilot September 9, 2026 21:08

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.

🟢 Approval recommended

The change directly prevents the reported NULL dereference and is covered by a focused new regression test.

Pull request overview

This PR fixes a crash in curl’s .netrc handling when the specified netrc file contains only a comment and does not end with a newline, and adds a regression test to cover that scenario.

Changes:

  • Avoid calling the netrc parser when the loaded netrc buffer is empty (prevents NULL dereference).
  • Add test 2429 to reproduce the “comment-only, no newline” .netrc case.
  • Register the new test in the autotools test data list.
File summaries
File Description
lib/netrc.c Adds an early return when the loaded netrc buffer is empty to avoid passing a NULL pointer into parsing.
tests/data/test2429 New regression test that uses a comment-only netrc file with nonewline="yes" and verifies a normal HTTP request occurs.
tests/data/Makefile.am Adds test2429 to the TESTCASES list so it’s included in the test suite.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bagder bagder closed this in 1143bc9 Sep 9, 2026
@bagder
bagder deleted the bagder/netrc-no-content branch September 9, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants