Merged
Conversation
Cyan4973
reviewed
Apr 30, 2021
|
|
||
| while (startOffset < endOffset) { | ||
| size_t const result = ZSTD_seekable_decompress(seekable, buffOut, MIN(endOffset - startOffset, buffOutSize), startOffset); | ||
| if (!result) { |
Contributor
There was a problem hiding this comment.
Nice optimization.
Is there more to it ? (does it dodge an error case ?)
Contributor
Author
There was a problem hiding this comment.
Is there more to it ?
Added the same for seekable_decompression_mem.c
(does it dodge an error case ?)
In theory before fixing frame overrun and not using checksums it is possible to go to endless loop
Cyan4973
reviewed
Apr 30, 2021
It tries to check the buffer boundary, but there is no buffer for from-file reading.
This will allow to read the whole file w/o gotting corruption error if
the offset is more then the data left in file, i.e.:
$ ./seekable_compression seekable_compression.c 8192 | head
$ zstd -cdq seekable_compression.c.zst | wc -c
4737
Before this patch:
$ ./seekable_decompression seekable_compression.c.zst 0 10000000 | wc -c
ZSTD_seekable_decompress() error : Corrupted block detected
0
After:
$ ./seekable_decompression seekable_compression.c.zst 0 10000000 | wc -c
4737
475c49a to
32d0813
Compare
Cyan4973
approved these changes
May 4, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog:
seekable_format: cap the offset+len up to the last dOffset
This will allow to read the whole file w/o gotting corruption error if
the offset is more then the data left in file, i.e.:
Before this patch:
After:
seekable_decompression: break when ZSTD_seekable_decompress() returns zero
seekable_decompression_mem: break when ZSTD_seekable_decompress() returns zero
seekable_format: fix from-file reading (not in-memory)