Skip to content

Preserve vendclass optarg when parsing enterprise number - #20

Open
nbromberg-dn wants to merge 2 commits into
v10.0.6-dnfrom
nbromberg/v26_4/SW-222918
Open

Preserve vendclass optarg when parsing enterprise number#20
nbromberg-dn wants to merge 2 commits into
v10.0.6-dnfrom
nbromberg/v26_4/SW-222918

Conversation

@nbromberg-dn

@nbromberg-dn nbromberg-dn commented Sep 6, 2026

Copy link
Copy Markdown

The vendclass parser split the enterprise number from its class data by writing a NUL into optarg.
dhcpcd applies command-line options more than once: first while processing global options, then again when each interface is configured.
That made the first pass succeed because it kept a local pointer to the bytes after the separator, but it permanently shortened the shared argv string to the enterprise number for later passes.

Parse the enterprise number from a temporary NUL-terminated copy instead, leaving argv intact so the per-interface pass can still see and encode the vendor-class data.

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 reviewed change resolves argument mutation with no unresolved issues.

Pull request overview

Preserves vendclass arguments across repeated command-line parsing.

Changes:

  • Parses the enterprise number from a temporary copy.
  • Avoids mutating shared argv data.
File summaries
File Description
src/if-options.c Safely parses vendclass without altering optarg.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

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

The vendclass parser split the enterprise number from its class data by writing a NUL into optarg.
dhcpcd applies command-line options more than once: first while processing global options, then again when each interface is configured.
That made the first pass succeed because it kept a local pointer to the bytes after the separator, but it permanently shortened the shared argv string to the enterprise number for later passes.

Parse the enterprise number from a temporary NUL-terminated copy instead, leaving argv intact so the per-interface pass can still see and encode the vendor-class data.

(cherry picked from commit 261851a from NetworkConfiguration#725)
@nbromberg-dn
nbromberg-dn force-pushed the nbromberg/v26_4/SW-222918 branch from 81498e4 to a3c67b9 Compare September 8, 2026 10:09

@ColinMcInnes ColinMcInnes 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.

Split the README change out into its own PR, it's unrelated to the vendclass optarg issue.

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.

5 participants