Repository navigation
Fix Test-Connection -BufferSize 0 reporting - #28589
Jacob Jefferson Cochran (jacjcoch) wants to merge 1 commit into
Conversation
Report the requested BufferSize parameter when constructing PingStatus for ping and traceroute replies. The default send buffer is intentionally empty, so buffer.Length cannot distinguish the default from an explicit -BufferSize 0. Also return the shared empty buffer for an explicit BufferSize of 0 so the unelevated Unix ping-utility fallback can accept it. Fixes PowerShell#27656 Co-authored-by: OpenCode <noreply@opencode.ai>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Jacob Jefferson Cochran (@jacjcoch) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Test-Connection buffer-size reporting fix.
No open issues 🎉
What changed in this PR
Fixes #27656 by making Test-Connection report an explicit -BufferSize 0 correctly while preserving default reporting.
Changes:
- Report the requested buffer size for ping and traceroute results.
- Reuse the shared empty buffer for zero-size requests to support unelevated Unix fallback.
- Add regression tests for zero and default buffer-size reporting.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 | Adds reporting tests without elevated-privilege requirements. |
| src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs | Corrects reported sizes and reuses the empty buffer for zero-size requests. |
Review effort: Balanced
Report the requested BufferSize parameter when constructing PingStatus for ping and traceroute replies. The default send buffer is intentionally empty, so buffer.Length cannot distinguish the default from an explicit -BufferSize 0.
Also return the shared empty buffer for an explicit BufferSize of 0 so the unelevated Unix ping-utility fallback can accept it.
Fixes #27656
Report the requested BufferSize parameter when constructing PingStatus for ping and traceroute replies. The default send buffer is intentionally empty, so buffer.Length cannot distinguish the default from an explicit -BufferSize 0.
Also return the shared empty buffer for an explicit BufferSize of 0 so the unelevated Unix ping-utility fallback can accept it.
Fixes #27656
PR Summary
Test-Connection -BufferSize 0 reported BufferSize as 32 because both ping and traceroute reporting used buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length. Since the default send buffer is intentionally empty, an explicit 0-byte buffer was indistinguishable from the default case and was misreported as 32, even though a 0-byte payload was sent.
This PR reports the requested BufferSize parameter instead, and treats BufferSize 0 as using the shared empty buffer in GetSendBuffer. The latter keeps -BufferSize 0 compatible with the .NET ping-utility fallback used on unelevated Unix, allowing the regression test to run without RequireSudoOnUnix.
Related prior attempts: #27657, #27905, #28568.
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header