Repository navigation
Fix to_signed_bytes_* for positive number with leading 0x80 - #72
Merged
Merged
Conversation
cuviper
requested changes
Dec 14, 2018
cuviper
left a comment
Member
There was a problem hiding this comment.
Ouch, nice catch! Can you just rustfmt this to wrap the long lines?
(musing) It might be good to have a test on the round trip to/from signed bytes, sweeping a decent range of numbers. Something like 0..u16::MAX plus a few more to get into 3 bytes, then both positive and negative.
Contributor
Author
|
@cuviper Formatted it. Yhea, could be something to fuzz even. |
Member
|
I've got that round trip test written that also shows your failure. I'll push it here in a moment. Fuzzing num-bigint would be awesome across the board! |
cuviper
approved these changes
Dec 14, 2018
Member
|
bors r+ |
bors Bot
added a commit
that referenced
this pull request
Dec 14, 2018
72: Fix `to_signed_bytes_*` for positive number with leading `0x80` r=cuviper a=leodasvacas The trick for saving a byte on `0x800000..` only works for negative numbers. This caused +128 to be serialized as `0x80` which is -128. So pretty bad bug. Co-authored-by: Leonardo Yvens Schwarzstein <leoyvens@gmail.com> Co-authored-by: Josh Stone <cuviper@gmail.com>
Contributor
Build succeeded |
Member
|
I published 0.2.2 -- thanks again! |
Contributor
Author
|
@cuviper Thanks for the super fast turnaround on this one! |
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.
The trick for saving a byte on
0x800000..only works for negative numbers. This caused +128 to be serialized as0x80which is -128. So pretty bad bug.