Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Incorrect handling of non-utf8 data #5

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

Incorrect handling of non-utf8 data #5

thejh opened this issue Aug 15, 2011 · 1 comment

Comments

@thejh
Copy link

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.

@kesla
Copy link
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 as completed in 1f90d16 Sep 8, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants