Repository navigation
Fix comp_size check for partial and unknown-size zip sources - #662
Closed
larancibia wants to merge 1 commit into
Closed
larancibia wants to merge 1 commit into
larancibia wants to merge 1 commit into
Conversation
Only enforce st.comp_size in zip_source_zip_file_create() when ZIP_STAT_COMP_SIZE is valid, check start > st.comp_size directly for open-ended reads (data_len < 0) instead of casting -1 to zip_uint64_t, and compare data_len against st.comp_size - start to avoid unsigned wraparound.
Member
|
Thanks, adapted and committed. |
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.
In
zip_source_zip_file_create(), the stored partial-read bounds checkstart + (zip_uint64_t)data_len > st.comp_sizeruns even whenZIP_STAT_COMP_SIZEis not set inst.validand castsdata_len == -1("read to end") toZIP_UINT64_MAX:ZIP_STAT_COMP_SIZEfail spuriously withZIP_ER_INCONS(comparing againstst.comp_size == 0).ZIP_STAT_COMP_SIZEand unknown uncompressed size (data_len == -1) fail spuriously atstart == 0(ZIP_UINT64_MAX > st.comp_size) and wrapstart + ZIP_UINT64_MAXtostart - 1whenstart > 0, missingstart == st.comp_size + 1.Guard the check on
have_comp_size, rejectstart > st.comp_sizefirst, and compare(zip_uint64_t)data_len > st.comp_size - startonly whendata_len >= 0.Adds a CMocka
run_test_tableunit test (regress/programs/source_zip_partial.c) covering pending sources withoutZIP_STAT_COMP_SIZE, exact stored boundaries,len == -1(start <= comp_sizevsstart > comp_size),start + len > comp_size, anduint64_twraparound, and setsPATHon CMocka tests so Windows shared-library builds locatezip.dll.