go-macaroon / js-macaroon

Javascript implementation of macaroons
BSD 3-Clause "New" or "Revised" License
41 stars 22 forks source link

[Bugfix] Avoid "RangeError: Invalid typed array length: 3355443200" when using more than 2 caveats #40

Closed guggero closed 5 years ago

guggero commented 5 years ago

I noticed that I get an error when using more than 2 caveats: RangeError: Invalid typed array length: 3355443200

Then I found out that the problem is the _grow function of ByteBuffer that always doubles the buffer in size and therefore grows exponentially, even if just one byte is added to the buffer.

My PR fixes this issue as well as two pre-existing bugs (there was a variable this._capacity in _grow that wasn't defined any more and I had to format test/verify.js to make eslint happy).

mhilton commented 5 years ago

@hatched can you take a look at this PR please?

hatched commented 5 years ago

Thanks for this pull request @guggero !