Skip to content

Commit

Permalink
Merge pull request #50 from ethereumjs/fix-buffer-to-int
Browse files Browse the repository at this point in the history
Use BN.toNumber() in bufferToInt. This ensures no overflow is allowed.
  • Loading branch information
wanderer authored Aug 22, 2016
2 parents 9a4e7b1 + 40aed6c commit 6afa374
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ exports.intToBuffer = function (i) {
* @method bufferToInt
* @param {Buffer} buf
* @return {Number}
* @throws If the input number exceeds 53 bits.
*/
exports.bufferToInt = function (buf) {
return parseInt(exports.bufferToHex(buf), 16)
return new BN(exports.toBuffer(buf)).toNumber()
}

/**
Expand Down

0 comments on commit 6afa374

Please sign in to comment.