Skip to content

Fix batch of minor issues - #41397

Open
Feng Wang (chemwolf6922) wants to merge 8 commits into
masterfrom
user/chemwolf6922/fix-batch-of-minor-issues-4
Open

Fix batch of minor issues#41397
Feng Wang (chemwolf6922) wants to merge 8 commits into
masterfrom
user/chemwolf6922/fix-batch-of-minor-issues-4

Conversation

@chemwolf6922

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

This PR fixes batch of minor issues found during AI code review.

src/linux/init/GnsPortTracker.cpp: 378
Fixed oversized socket-address allocations from malicious inputs.

src/linux/init/main.cpp: 2173
Fixed mini init overwriting a distribution symlink target.

src/windows/common/WslClient.cpp: 259
src/windows/common/precomp.h: 100
test/windows/UnitTests.cpp: 172
Fixed conflicting export formats being accepted together.

src/windows/common/WslClient.cpp: 928
test/windows/UnitTests.cpp: 4371
Fixed command injection through --set-default-user.

src/windows/service/exe/WslCoreGuestNetworkService.cpp: 95
Fixed the guest network service VM ID not being stored.

src/windows/service/exe/WslCoreNetworkEndpoint.h: 20
Fixed network endpoint move assignment leaking the replaced endpoint.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Update tests:
UnitTests::ExportDistro
UnitTests::ManageDefaultUid

@chemwolf6922
Feng Wang (chemwolf6922) requested a review from a team as a code owner August 20, 2026 09:46
Copilot AI lite review requested due to automatic review settings August 20, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 batches several targeted correctness and security hardening fixes across WSL’s Linux init and Windows client/service components, and adds/updates Windows unit tests to validate the behavior.

Changes:

  • Hardened input/file handling on the Linux init side (sockaddr length validation; avoid clobbering symlink targets when creating the mini-init mount point).
  • Tightened Windows CLI behavior (reject multiple export formats; avoid command injection when resolving --manage --set-default-user).
  • Fixed service/network lifecycle issues (persist guest network service VM ID; ensure network endpoint move-assignment deletes the replaced endpoint to avoid leaking HNS endpoints).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/windows/UnitTests.cpp Adds regression coverage for invalid export format combinations and --set-default-user injection attempts.
src/windows/service/exe/WslCoreNetworkEndpoint.h Adds explicit move-assignment to delete the replaced HNS endpoint and prevent endpoint leaks.
src/windows/service/exe/WslCoreGuestNetworkService.cpp Stores VM ID after guest network service creation so deletion uses the correct identifier.
src/windows/common/WslClient.cpp Uses std::popcount to reject multiple export format flags; switches --set-default-user UID lookup to argv-safe command line construction.
src/windows/common/precomp.h Adds <bit> for std::popcount.
src/linux/init/main.cpp Prevents symlink target overwrite by unlinking the target then using O_EXCL create for the init mount target.
src/linux/init/GnsPortTracker.cpp Rejects oversized sockaddr lengths to avoid oversized allocations from malicious inputs.

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

Comment thread src/windows/common/WslClient.cpp Outdated
Comment thread test/windows/UnitTests.cpp Outdated
Copilot AI review requested due to automatic review settings August 20, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

OneBlue
Blue (OneBlue) previously approved these changes Aug 20, 2026

@OneBlue Blue (OneBlue) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, feel free to address comments in a followup

Comment thread src/windows/service/exe/WslCoreNetworkEndpoint.h
Comment thread test/windows/UnitTests.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

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.

3 participants