Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BN parses invalid characters #151

Closed
kumavis opened this issue Nov 7, 2016 · 7 comments
Closed

BN parses invalid characters #151

kumavis opened this issue Nov 7, 2016 · 7 comments

Comments

@kumavis
Copy link
Contributor

kumavis commented Nov 7, 2016

bn = new BN('xxx', 16)
<BN: 888>

@danfinlay
Copy link

Yeah, I just ran into this, took a long time to debug, because I assumed hex-prefixed base 16 would be digested gracefully.

> var a = new BN('0x01', 16)
undefined
> a
<BN: 801>

Hex prefixes should be removed automatically, and otherwise invalid characters should throw a descriptive error.

danfinlay added a commit to MetaMask/metamask-extension that referenced this issue Nov 7, 2016
Our gas price buffering logic had a bug, because bn.js has inconsistent behavior when using hex-prefixed output.  The issue has been opened with them here:
indutny/bn.js#151

We've corrected our usage in the mean time.
@fanatid
Copy link
Collaborator

fanatid commented Nov 7, 2016

related with #141
unfortunately that PR don't fix this issue

@danfinlay
Copy link

If it throws an error for the hex prefix, I'd consider that mostly solving the issue. Wouldn't the x trigger an error in that PR?

@fanatid
Copy link
Collaborator

fanatid commented Nov 7, 2016

@FlySwatter I already checked and looks like that PR don't throw error
as I understand it is happens because #141 fix _parseBase, but when base equal 16 _parseHex is used..

@axic
Copy link
Contributor

axic commented Nov 7, 2016

Also: #90 & #91 (#91 actually implements the fix)

@kumavis
Copy link
Contributor Author

kumavis commented Jan 24, 2017

Just ran in to this again omg fml

@dcousens
Copy link
Contributor

@kumavis wrap the BN constructor in something that is stricter so as to avoid this issue.

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

No branches or pull requests

5 participants