Fix overflow issues on writing/reading integers #11

merged 1 commit into from Feb 27, 2013

2 participants


buffer-browserify does not handle writing and reading out of bounds correctly.

  • If you write value out-of-bounds and read it back you always get the full value back. Nothing is cut off.
  • If you write value out-of-bounds it can leak to the next buffer in SlowBuffer.

This PR only fixes Integers. Floats probably have same issues.


Hi and thanks for you work!

Is the overflow present in node's original module? Even though it is a bug, I want to stick to node's implementation as much as possible so that there's no surprise when running code on browserify that has been written for node..


Yes, this is the way node handles overflow. I also added a testcase that compares results from node to this module.

The implementation is different because in node its based on fixed length typed-array and there is no way to write over the length of the buffer. In buffer-browserify it just directly accesses slowbuffer and length has no special meaning.


Oh, my bad I did not see the test. Merging, thanks!

@toots toots merged commit 0ab6b0e into toots:master Feb 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment