Repository navigation
pxf: bound a Decimal before rendering it - #56
Merged
Merged
Conversation
Marshal padded a scale one digit at a time, so a scale near INT32_MAX never finished, and it dropped a negative scale, changing the value. The PB decoder's bound doesn't cover a message read by a protobuf runtime. Refuse past MaxNumericLiteralDigits on both signs before any work, as protowire-go does, and bound the literal. protowire#448
Reads the bytes with the stock protobuf runtime, which stores the fields and bounds nothing, then writes PXF. Bypassing the hardened decoder is the point: otherwise the row is refused before the encoder runs. protowire#448
clang-tidy runs on headers with inferred flags, which don't always carry the include root, so pb_big.h's first project include failed to resolve.
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.
Part of trendvidia/protowire#448. Rendering a stored
pxf.Decimalto PXF had no bound, so a five-byte scale could stall or exhaust the encoder. This now matches protowire-go'sreadDecimalStr: a scale pastMaxNumericLiteralDigitsfails on either sign before any work, aBigIntorDecimalliteral past the digit cap fails, and padding is linear. It reaches a message read by a protobuf runtime, which a PB decoder's own bound doesn't cover.A negative scale also kept its digits but lost its value:
5at scale-2came out as5. It now renders500.Checked
305 tests pass locally, 4 of them new. The HARDENING corpus passes on this branch. It doesn't yet test rendering, which is what the rest of #448 adds.