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

Fix error in decompressing RDS files that decompress to more than UINT_MAX bytes #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elaude
Copy link

@elaude elaude commented Apr 22, 2024

When decompressing RDS files that decompress to more than UINT_MAX bytes (~4 GB), librdata incorrectly returns an error Could not open file.

This is caused by truncating assignment of an 8 byte ssize_t to a 4 byte uInt. 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 -Wconversion flag 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.

…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).
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

Successfully merging this pull request may close these issues.

1 participant