Skip to content

netrc: skip malformed macdef lines#21049

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/netrc-macdef
Closed

netrc: skip malformed macdef lines#21049
bagder wants to merge 1 commit intomasterfrom
bagder/netrc-macdef

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Mar 21, 2026

When skipping macdef lines inside netrc files, ignore it completely and do not tokenize or bail out on bad quotes.

Follow-up to 3b43a05

Spotted by Codex Security

@github-actions github-actions bot added the tests label Mar 21, 2026
@bagder bagder requested a review from Copilot March 21, 2026 21:45
@bagder bagder marked this pull request as ready for review March 21, 2026 21:45
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 .netrc parser’s handling of macdef sections so malformed content inside a macro definition (e.g., broken quotes) is skipped without tokenization or parse failures, and adds a regression test to cover the scenario.

Changes:

  • Update netrc_get_token() to treat MACDEF state as “skip the entire line” and never tokenize macro-body content.
  • Add new regression test test1672 exercising a macdef containing a broken quote followed by a valid machine entry.
  • Register the new test in tests/data/Makefile.am.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/netrc.c Ensures macdef lines are fully ignored during parsing to avoid failures on malformed tokens/quotes.
tests/data/test1672 Adds a regression test netrc file with macdef content containing a broken quote.
tests/data/Makefile.am Includes test1672 in the distributed/known test list.

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

When skipping macdef lines inside netrc files, ignore it completely and
do not tokenize or bail out on bad quotes.

Follow-up to 3b43a05

Spotted by Codex Security
@bagder bagder force-pushed the bagder/netrc-macdef branch from 8261f86 to 7e04c67 Compare March 21, 2026 21:57
@bagder bagder closed this in fa13f37 Mar 21, 2026
@bagder bagder deleted the bagder/netrc-macdef branch March 21, 2026 22:21
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