-
Notifications
You must be signed in to change notification settings - Fork 2.2k
decodecorpus #1664
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
decodecorpus #1664
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me, but I'll let Yann take a look.
How probable is it that decodecorpus
generates a block that triggers this bug? Starting on a random seed, approximately how long does it take to generate an offending block?
Add test case for short bistream
@terrelln |
A targeted test case for an extreme outlier, |
tests/zstreamtest.c
Outdated
CHECK_Z( ZSTD_decompressStream(zds, &outBuff, &inBuff) ); | ||
} | ||
|
||
{ XXH64_state_t xxhStateIn, xxhStateOut; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if all you want to do is compare decompressed
and decodedBuffer
content and ensure they are equal, you could simply memcmp()
them.
tests/zstreamtest.c
Outdated
outBuff.pos = 0; | ||
|
||
while (inBuff.pos < inBuff.size) { | ||
CHECK_Z( ZSTD_decompressStream(zds, &outBuff, &inBuff) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's slightly stronger than CHECK_Z()
:
presuming the frame is complete (is it ?), you want a return value 0
, to indicate that the decoder has reached the end of frame. You also want to ensure it has consumed the entire input (inBuff.pos == inBuff.compressedSize
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a complete frame.
Looks good ! |
reflect code review comments
Decoder was enforcing a constraint that is more strict than the spec. Sequence section for a compressed block can be less than the constraint that was enforced by decoder. When a block with rle mode for all (literal length, match length, and offset) is followed by another block with repeat mode for all (literal length, match length, and offset), the second block's sequence section can be 2 bytes (1 byte for number of sequences and 1 byte for compression mode for each field).
This pull request includes 2 changes.
Run
./decodecorpus -ptestfiles -otestfiles -n1 -s1236947365 -v
to generate an input that has an issue before the fix.