Skip to content

Add runtime test for IPC profiler command validation with truncated payloads#124056

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-runtime-test-ipc-profiler
Draft

Add runtime test for IPC profiler command validation with truncated payloads#124056
Copilot wants to merge 2 commits intomainfrom
copilot/add-runtime-test-ipc-profiler

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Description

Adds runtime tests validating that the diagnostic server properly rejects IPC profiler commands when payload fields claim more data than actually exists. This covers the client_data_len validation at line 73 of ds-profiler-protocol.c as discussed in #122257.

Test cases added

  • AttachProfilerCommand_TruncatedClientData_ReturnsError - client_data_len claims 1000 bytes, provides 0
  • StartupProfilerCommand_TruncatedString_ReturnsError - profiler_path string length claims 1000 chars, provides 2
  • AttachProfilerCommand_TruncatedGuid_ReturnsError - GUID field provides 8 bytes instead of 16

All tests verify the server returns DS_IPC_E_BAD_ENCODING (0x80131384).

Example payload construction

// Construct malformed AttachProfiler payload
using (var stream = new MemoryStream())
using (var writer = new BinaryWriter(stream))
{
    writer.Write((uint)1000);                    // attach_timeout
    writer.Write(Guid.NewGuid().ToByteArray());  // profiler_guid
    writer.Write((uint)(path.Length + 1));       // profiler_path length
    writer.Write(Encoding.Unicode.GetBytes(path + '\0'));
    writer.Write((uint)1000);                    // client_data_len (claims 1000)
    // Intentionally omit actual client_data bytes
}
Original prompt

Can you add an runtime test that validates the behavior when the diagnostic server parses an IPC profiler command that has less data than the client_data_len suggests, as brought up in #122257 (comment). Ideally it would be through using the Microsoft.Diagnostics.NETCore.Client library, but I'm guessing that might not expose an api that allows customization of the client data bytes passed


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mdh1418 <16830051+mdh1418@users.noreply.github.com>
Copilot AI changed the title [WIP] Add runtime test for IPC profiler command validation Add runtime test for IPC profiler command validation with truncated payloads Feb 5, 2026
Copilot AI requested a review from mdh1418 February 5, 2026 19:13
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants