Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Intermittent failure in Buffer::Base64Write with zero-length string #2657

Closed
rvermillion opened this Issue · 2 comments

2 participants

@rvermillion

When a zero-length string is written to a Buffer, a Buffer from the pool with zero bytes remaining can be selected and will then throw an exception because offset is equal to the buffer length.

This error was occurring sporadically with the node-hbase module which uses buffers to decode the Base64 content, sometimes empty strings, from the HBase REST server.

Adding a check in Buffer::Base64Write for zero-length strings will skip that check and return 0 with less work. I will submit a patch to v0.6.9 that fixes the bug.

@bnoordhuis

Confirmed. I can reproduce it with this one-liner:

for (var n = 1; n <= 8192; ++n) {
  new Buffer(n);
  new Buffer(0).write('', 0, 0, 'base64'); 
}

The other encodings (hex, ascii, utf8, ucs2, binary) don't have this problem.

@bnoordhuis

I see you've opened a pull request. Let's continue in #2659.

@bnoordhuis bnoordhuis closed this
@bnoordhuis bnoordhuis referenced this issue from a commit in bnoordhuis/node
@bnoordhuis bnoordhuis buffers: fix intermittent out of bounds error
The base64 decoder would intermittently throw an out-of-bounds exception when
the buffer in `buf.write('', 'base64')` was a zero-sized buffer located at the
end of the slab.

Fixes #2657.
ca77de2
@isaacs isaacs referenced this issue from a commit in isaacs/node
@bnoordhuis bnoordhuis buffers: fix intermittent out of bounds error
The base64 decoder would intermittently throw an out-of-bounds exception when
the buffer in `buf.write('', 'base64')` was a zero-sized buffer located at the
end of the slab.

Fixes #2657.
7e40c7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.