Repository navigation
fix: refuse a NUL in integer bounds and elements - #242
Merged
Merged
Conversation
IntegerLiteral's fast path is the BCL TryParse with NumberStyles.Integer, which ignores trailing
NULs, so Int32Range.ParseValue("31\0") was 31, {"31\0"} was {31}, and JSON literals followed. The
#127 slow path always refused 0x1F\0 and 1_0\0, and the decimal, float, temporal and Guid families
refuse a NUL; PostgreSQL text cannot hold one. IntegerLiteral now refuses U+0000 before either path,
which every integer ParseValue, literal, JSON element and TypeConverter reaches. Older than 10.0.0,
silent, and a tightening, so it goes in the major's Breaking list.
IntegerLiteralGrammarTests: ParseValue_RejectsANul (five types × seven rows) and
Literals_RejectANul. With the check removed, the three trailing-NUL rows and the literal test fail;
a leading or inner NUL was already refused.
Closes #233
Found-By: CA
Defect-Class: LIT
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 19, 2026
Owner
Author
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.
Closes #233
Problem
Integer bounds and elements accepted a trailing NUL, which PostgreSQL text can't hold:
Int32Range.ParseValue("31\0")returned 31.Int16Set.Parse("{\"31\0\"}")returned{31}.IntegerLiteral's fast path is the BCLTryParsewithNumberStyles.Integer, which ignores trailing NULs. The #127 slow path already rejected0x1F\0and1_0\0, and the decimal, float, temporal and Guid families reject a NUL. This is older than 10.0.0 and silent, and fixing it is a tightening, so it ships in this major.Change
IntegerLiteral.Parserejects U+0000 before either path. Every integerParseValuegoes through it, so every literal, set element, JSON value, TypeConverter call and EF bridge read is covered.docs/migration.md(v9.x): the NUL bullet and the "Keep NUL out of string elements" section now cover integer text too.Tests
IntegerLiteralGrammarTests.ParseValue_RejectsANulcovers 7 NUL rows (trailing, doubled, leading, inner, hex, separator) across all five integerParseValues.Literals_RejectANulcovers a range, a multirange, a quoted and an unquoted set element, a JSON range, and a JSON set read withAllowReadingFromString.Literals_RejectANulfail ("no exception was thrown"). The leading and inner NUL rows pass either way: those were already rejected, and they guard against a looser fix.🤖 Generated with Claude Code