Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid block checksum #56

Open
alexfernandez opened this issue Dec 15, 2017 · 0 comments
Open

Invalid block checksum #56

alexfernandez opened this issue Dec 15, 2017 · 0 comments

Comments

@alexfernandez
Copy link

After compressing a block and decompressing it with blockChecksum enabled, node-lz4 bombs:

    const decoder = lz4.createDecoderStream({
      });
      const encoder = lz4.createEncoderStream({ 
        blockChecksum: true,
        //debug: true,
      })
      const buffers = []
      encoder.on('data', data => decoder.write(data))
      encoder.on('end', () => decoder.end())
      decoder.on('data', data => buffers.push(data))
      decoder.on('end', () => {
        console.log('Received %s', Buffer.concat(buffers))
      })
      encoder.end('panchi pinchi pinchi panchi punchi\n')

results in:

Invalid block checksum: 3942400633 vs 3364695891 for {"type":"Buffer","data":[153,112,97,110,99,104,105,32,112,105,7,0,3,21,0,96,117,110,99,104,105,10]} @26

After investigating in the guts of lib/encoder_stream.js here it appears that it computes the checksum on a buffer that contains the compressed block, and some padding: instead of only 9970616e636869207069070003150060756e6368690a it hashes 9970616e636869207069070003150060756e6368690a0000000000000000000000000000000000000000000000000000000000, which yields the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant