Skip to content

fix: NUL-terminate config_readline() when the file lacks a final newline - #81

Merged
rd235 merged 1 commit into
masterfrom
vde-router-config-eof
Oct 3, 2026
Merged

rd235 merged 1 commit into
masterfrom
vde-router-config-eof

Conversation

@danielinux

Copy link
Copy Markdown
Member

Fixes #63

vde_router.c:1385: the config_readline() buffer was not NUL-terminated when EOF
was reached mid-line, so the router config reader could see a garbage tail.

Verified: host build passes.

If read() returns EOF in the middle of a line, the loop exited without
terminating the buffer and the caller passed an unterminated string to
handle_cmd(). Terminate it before returning; the len == MAXCMD
truncation path already zeroed the last byte.

Fixes #63.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 11:37

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.

Copilot review overview

🟢 Approval recommended

The focused change correctly prevents stale buffer contents from affecting the final configuration command.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes parsing of configuration files whose final line lacks a newline.

Changes:

  • NUL-terminates partially read final configuration lines.
  • Preserves existing handling for full buffers and newline-terminated lines.
File Description
src/​vde_router/​vde_router.c Ensures config_readline() returns a terminated string at EOF.

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

@rd235 rd235 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fix ok

@rd235
rd235 merged commit 5a2ae0f into master Oct 3, 2026
3 checks passed
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.

vde_router: dhcp line in config file not terminating with "<return>" gets mishandled

3 participants