Skip to content

Restore validateIntegerLength() check in _decodeBigInt - #680

Merged
cowtowncoder merged 3 commits into
FasterXML:3.xfrom
tonghuaroot:fix/yaml-decodebigint-validate-integer-length
May 25, 2026
Merged

Restore validateIntegerLength() check in _decodeBigInt#680
cowtowncoder merged 3 commits into
FasterXML:3.xfrom
tonghuaroot:fix/yaml-decodebigint-validate-integer-length

Conversation

@tonghuaroot

Copy link
Copy Markdown
Contributor

On the 3.x branch, YAMLParser._decodeBigInt routes its input string straight to NumberInput.parseBigInteger / parseBigIntegerWithRadix without first running it through StreamReadConstraints.validateIntegerLength. The configured maxNumberLength cap therefore does not constrain integer literals that exit through this helper, including hex / octal / binary !!int radix scalars and any decimal scalar long enough to fall through to it.

This change adds the length check at the top of the method, mirroring the 2.x implementation and the surrounding number-validation helpers (_cleanYamlInt, _cleanYamlFloat) in the same file.

Regression coverage added in IntegerLengthRadixTest for decimal, hex, octal, and binary !!int literals against a YAMLFactory configured with maxNumberLength(1000). Three of the four cases fail before the patch and pass after; the decimal one already passed via the existing _cleanYamlInt check and is included as a sanity guard.

2.x already has this check, so no backport is needed.

The 3.x YAMLParser._decodeBigInt routes the input string straight to
NumberInput.parseBigInteger / parseBigIntegerWithRadix without first
running it through StreamReadConstraints.validateIntegerLength, which
means the configured maxNumberLength cap does not constrain integer
literals that exit through this path (notably hex / octal / binary
radix scalars and any decimal scalars reaching this helper).

This change adds the length check at the top of the method, matching
the 2.x implementation and the surrounding number-validation helpers
in the same file. Adds regression coverage for decimal, hex, octal,
and binary !!int literals against a YAMLFactory configured with
maxNumberLength(1000).
@cowtowncoder cowtowncoder added yaml Issue related to YAML format backend 2.18 Fix or feature targeted at 2.18 release 3.1 and removed 2.18 Fix or feature targeted at 2.18 release labels May 25, 2026
@cowtowncoder cowtowncoder changed the title [yaml] Restore validateIntegerLength check in _decodeBigInt Restore validateIntegerLength() check in _decodeBigInt May 25, 2026
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 70.83% 📈 +0.040%
Branches branches 65.49% 📈 +0.000%

Coverage data generated from JaCoCo test results

@cowtowncoder cowtowncoder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cowtowncoder
cowtowncoder merged commit ba7b675 into FasterXML:3.x May 25, 2026
3 checks passed
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 70.83% 📈 +0.040%
Branches branches 65.49% 📈 +0.000%

Coverage data generated from JaCoCo test results

cowtowncoder added a commit that referenced this pull request May 25, 2026
@cowtowncoder cowtowncoder added this to the 3.1.4 milestone May 25, 2026
@cowtowncoder

Copy link
Copy Markdown
Member

Thank you @tonghuaroot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.1 yaml Issue related to YAML format backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants