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

Already on GitHub? Sign in to your account

Incorrect handling of non-utf8 data #5

Closed
thejh opened this Issue Aug 15, 2011 · 1 comment

Comments

Projects
None yet
2 participants

thejh commented Aug 15, 2011

As it seems, snappy converts input to strings before it actually handles it which can completely destroy your data:

> new Buffer(new Buffer([255]).toString())
<Buffer ef bf bd>
> snappy.compressSync(new Buffer([255]), function(err,data){gerr=err;gdata=data})
> gdata
<Buffer 03 08 ef bf bd>
> snappy.compressSync(new Buffer([255]), function(err,data){gerr=err;gdata=data})
> gdata
<Buffer 03 08 ef bf bd>
> snappy.compressSync(new Buffer([0xef,0xbf,0xbd]), function(err,data){gerr=err;gdata=data})
> gdata
<Buffer 03 08 ef bf bd>

Same applies for uncompressing.

Owner

kesla commented Aug 18, 2011

Hi!

Thanks for the bug report!

I've reproduced the error that you're describing. I'll try to sort it out and add a test case for the behavior later on.
Stay tuned.

@kesla kesla closed this in 1f90d16 Sep 8, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment