Skip to content

apd: prevent NewFromString parsing invalid decimals#147

Closed
mw5h wants to merge 1 commit intocockroachdb:masterfrom
mw5h:fix-setstring-sign
Closed

apd: prevent NewFromString parsing invalid decimals#147
mw5h wants to merge 1 commit intocockroachdb:masterfrom
mw5h:fix-setstring-sign

Conversation

@mw5h
Copy link
Contributor

@mw5h mw5h commented Mar 13, 2026

Cherry-pick of @jms-bc's fix from #145, rebased onto current master so CI runs with the updated workflow from #146.

Summary

Fixes a parsing bug (#144) where sign characters (+, -) immediately after a decimal point bypass setString's sign validation and are passed to big.Int.SetString, which accepts them. This produces corrupt Decimal values.

The fix validates that the mantissa contains only ASCII digits (0-9) after the decimal point and exponent have been removed, before it is passed to big.Int.SetString.

Original author: @jms-bc
Original PR: #145
Related issues: #144, #120

Reject non-digit characters in the mantissa.
@mw5h mw5h closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants