airlift / aircompressor

A port of Snappy, LZO, LZ4, and Zstandard to Java
Apache License 2.0
562 stars 111 forks source link

verify magic for all frames #147

Closed arnej27959 closed 2 years ago

arnej27959 commented 2 years ago

I'm writing an implementation of ZstdInputStream for contribution, and noticed a minor bug. When decompressing multiple frames all calls to verifyMagic would use the address of the first frame.

martint commented 2 years ago

Thanks! Can you add a test for this? We can add a file with multiple frames an a bad magic header in one of the frames other than the first one.

arnej27959 commented 2 years ago

ok, I duplicated src/test/resources/data/zstd/multiple-frames.zst and changed the magic in the second frame. this triggers as expected if I revert the first commit: Method TestZstd.testVerifyMagicInAllFrames()[pri:0, instance:io.airlift.compress.zstd.TestZstd@5e600dd5] should have thrown an exception of type class io.airlift.compress.MalformedInputException

arnej27959 commented 2 years ago

@martint ping - I will have the next pull request ready as soon as this one is merged :-)

arnej27959 commented 2 years ago

commits squashed into one now.

arnej27959 commented 2 years ago

Note: Githubs tells me

1 workflow awaiting approval
First-time contributors need a maintainer to approve running workflows

and therefore the CI job has not run for this pull request.