Repository navigation
Reject NUL characters in Metadata TypeName parsing - #137922
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @steveisok, @dotnet/area-system-reflection |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
jkotas
commented
Nov 19, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
jkotas
commented
Nov 19, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
AaronRobinsonMSFT
approved these changes
Nov 20, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new theory fails on Mono because its native NUL-terminated parser resolves "System.Int32\0junk" rather than returning null, so it needs an IsNotMonoRuntime condition or a corresponding Mono parser fix.
1 open issue
What changed in this PR
This PR addresses the mismatch between metadata type-name validation and runtime loading by rejecting embedded NUL characters in the shared type-name parser.
Changes:
- Treat NUL as a parsing delimiter and reject escaped NUL characters.
- Preserve NUL characters when constructing simple metadata type names.
- Add parser and runtime-loading regression cases for simple, nested, generic, assembly-qualified, and escaped names.
| File | Description |
|---|---|
src/libraries/System.Runtime/tests/System.Reflection.Tests/GetTypeTests.cs |
Adds NUL rejection tests for runtime type loading. |
src/libraries/System.Reflection.Metadata/tests/Metadata/TypeNameTests.cs |
Tests parsing rejection and preservation during simple-name construction. |
src/libraries/System.Reflection.Metadata/tests/Metadata/TypeNameParserHelpersTests.cs |
Tests delimiter offsets and escaped-NUL rejection. |
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserHelpers.cs |
Updates shared parsing while preserving NUL during escaping. |
Review effort: Balanced
jkotas
marked this pull request as ready for review
November 24, 2026 04:56
Member
Author
|
/ba-g dead letter + #138194 |
This was referenced Nov 24, 2026
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.

TypeName.Parsepreserves embedded NULs, while runtime type loading can truncate names at them. This allows validation and loading to interpret the same string differently.ParsethrowsArgumentException;TryParsereturnsfalse.