Fix error in decompressing RDS files that decompress to more than UINT_MAX bytes#49
Open
elaude wants to merge 1 commit intoWizardMac:masterfrom
Open
Fix error in decompressing RDS files that decompress to more than UINT_MAX bytes#49elaude wants to merge 1 commit intoWizardMac:masterfrom
elaude wants to merge 1 commit intoWizardMac:masterfrom
Conversation
…T_MAX bytes This was caused by truncating assignment of an 8 byte ssize_t to a 4 byte uInt. Fixed by doing saturating assignment instead. The surrounding decompression loop ensures that larger files can be decompressed (in chunks).
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.
When decompressing RDS files that decompress to more than
UINT_MAXbytes (~4 GB), librdata incorrectly returns an errorCould not open file.This is caused by truncating assignment of an 8 byte
ssize_tto a 4 byteuInt. I fixed this by doing saturating assignment instead. The surrounding decompression loop ensures that larger files can be decompressed (in chunks).C.f https://github.com/madler/zlib/blob/develop/uncompr.c#L58 for a reference implementation that works this way.
I only fixed the bug that I could personally confirm fixed with my changes, the analogous functions using gzip or lzma decompression likely still have similar bugs.
Please consider turning on the
-Wconversionflag for gcc, as this correctly warns about the assignment that caused this bug. When briefly turning on-Wconversion, I got a large number of warnings about other lines in the codebase.