Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies a set of small correctness fixes across Windows and Linux components of the WSL codebase, primarily addressing copy/paste mistakes, boundary conditions, and API return-value handling.
Changes:
- Fixes multiple control-flow and boundary-condition issues (missing
break, off-by-one in wait result checks, fallthrough in parsers). - Corrects API usage/return-value checks and formatting (Win32 BOOL vs HRESULT, pthread/getpwuid_r/getgrnam_r semantics, logging format strings).
- Improves robustness/clarity in shared utilities (hostname truncation ordering, safer MessageWriter index bounds check, configfile parsing logic).
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows/service/exe/WslCoreVm.cpp | Adds missing break in port tracker switch to avoid unintended fallthrough. |
| src/windows/service/exe/LxssUserSession.cpp | Fixes ExecutionContext to use Context::MountDisk for MountDisk. |
| src/windows/service/exe/DistributionRegistration.cpp | Removes duplicate registry write of Property::Flags. |
| src/windows/common/relay.cpp | Fixes off-by-one check for WaitForMultipleObjects results. |
| src/windows/common/helpers.cpp | Fixes off-by-one wait result handling; fixes timezone string resizing to use returned size. |
| src/windows/common/WslCoreNetworkingSupport.cpp | Fixes dynamic function loading to load into the correct function objects. |
| src/windows/common/HandleConsoleProgressBar.cpp | Fixes GetFileSizeEx failure handling (BOOL-returning API, not HRESULT). |
| src/shared/inc/stringshared.h | Ensures cleaned hostname is truncated before trailing ./- trimming and default handling. |
| src/shared/inc/message.h | Reworks relative-index bounds validation and removes unused member. |
| src/shared/configfile/configfile.cpp | Fixes malformed-quote handling logic when overwriting/removing keys during config update. |
| src/linux/plan9/p9util.cpp | Fixes getpwuid_r/getgrnam_r error checks to match their return convention. |
| src/linux/plan9/p9readdir.cpp | Adds missing semicolon after THROW_LAST_ERROR_IF. |
| src/linux/plan9/p9io.cpp | Simplifies AIO callback result computation and aligns aio_write error return sign (but see review comment). |
| src/linux/plan9/p9file.h | Fixes getpwuid_r error check in Root initialization. |
| src/linux/netlinkutil/NetlinkMessage.hxx | Fixes attribute bounds error message to reference sizeof(TAttribute). |
| src/linux/netlinkutil/Interface.cpp | Fixes IFNAMSIZ boundary; avoids writing NUL terminator into sysctl-style procfs values. |
| src/linux/mountutil/mountutil.c | Adds missing break to prevent switch fallthrough after parsing device field. |
| src/linux/init/wslinfo.cpp | Corrects header comment to refer to wslinfo (but see review comment). |
| src/linux/init/util.cpp | Fixes early return on failed accept4; removes unreachable/incorrect loop error handling. |
| src/linux/init/plan9.cpp | Fixes log formatting for setrlimit output. |
| src/linux/init/main.cpp | Fixes pthread return check, initialization, variable shadowing, sockaddr initialization, and parsing condition. |
| src/linux/init/config.cpp | Fixes log formatting for buffer size output. |
| src/linux/init/SecCompDispatcher.cpp | Fixes log formatting specifiers/types for seccomp notification logging. |
| src/linux/init/DnsServer.cpp | Removes redundant/overwritten epoll_event.data.fd assignment when using data.ptr. |
| src/linux/inc/lxwil.h | Fixes pipe2 error check condition. |
OneBlue
reviewed
Apr 16, 2026
Collaborator
OneBlue
left a comment
There was a problem hiding this comment.
Lots of great fixes in there, looks great ! Couple minor questions
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/linux/plan9/p9util.cpp:169
getpwuid_r()returns an error number directly; this loop checkserrno != ERANGEto decide whether to grow the buffer. That relies onerrnobeing set, which isn’t guaranteed by the API contract. Capture the return value fromgetpwuid_r()and compare it toERANGEinstead (and use that same return value for the non-ERANGE error path).
if (getpwuid_r(uid, &pwd, buffer.data(), size, &result) != 0)
{
if (errno != ERANGE)
{
return c_InvalidGid;
src/linux/plan9/p9util.cpp:205
getgrnam_r()returns an error number directly; the ERANGE retry logic should check the function’s return value rather thanerrnoto decide whether to resize/retry. This avoids relying onerrnobeing set by the implementation.
if (getgrnam_r(name, &grp, buffer.data(), size, &result) != 0)
{
if (errno != ERANGE)
{
return c_InvalidGid;
benhillis
pushed a commit
that referenced
this pull request
Apr 17, 2026
Bugs fixed (not covered by PR #40197): - unittests.c: Fix get_addr_info test entry pointing to wrong handler (GetSetIdTestEntry -> GetAddrInfoTestEntry) - SocketChannel.h: Fix %s format specifier in fmt-style LOG_ERROR on Linux; channel name was silently dropped from protocol error logs - p9file.cpp: Fix readlinkat return type (int -> ssize_t) to match POSIX specification - configfile.cpp: Guard ungetwc() call against WEOF to avoid undefined behavior on some implementations - init.cpp: Fix SIGCHLD race by blocking the signal before setting the handler, preventing a window where child exit could be lost - util.cpp: Extract duplicated signal skip list into SkipSignal() helper to ensure consistency between save and set handlers Test improvements: - NetworkTests.cpp: Add SO_RCVTIMEO timeout on accept() to prevent indefinite test hangs (resolves TODO) - DrvFsTests.cpp: Add LOG_IF_WIN32_BOOL_FALSE to cleanup operations to surface silent file/directory deletion failures Script hardening: - copy_and_build_tests.ps1: Replace Invoke-Expression with call operator to prevent command injection via interpolated variables - test-setup.ps1: Pass PostInstallCommand through bash -c for proper shell argument handling - deploy-to-vm.ps1: Prompt for password via Read-Host -AsSecureString when not provided, instead of creating empty SecureString Resource management: - WslConfigService.cs: Dispose FileSystemWatcher in destructor to prevent resource leak Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
benhillis
pushed a commit
that referenced
this pull request
Apr 17, 2026
Full deep review covering 7 subsystems with 44 findings. 12 fixes on this branch, 10+ already in PR #40197, 4 deferred. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
This PR fixes a batch of minor bugs / issues found during code review.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed