Reject ZIP_FL_LOCAL|ZIP_FL_CENTRAL in zip_file_extra_field_get_by_id() - #565
Open
Nexory wants to merge 1 commit into
Open
Reject ZIP_FL_LOCAL|ZIP_FL_CENTRAL in zip_file_extra_field_get_by_id()#565Nexory wants to merge 1 commit into
Nexory wants to merge 1 commit into
Conversation
Since local and central extra fields are kept in separate lists, an extra field index can not address both at once: it is applied to each list in turn, so the first match wins and fields behind it are silently skipped. With one local and two central fields of the same id, zip_file_extra_fields_count_by_id() reports 3 while index 0 returns the local field, index 1 the second central one, and index 2 ZIP_ER_NOENT. The first central field is not reachable at any index, and index 1 returns a valid pointer to the wrong field rather than an error. Reject the combination the way zip_file_extra_field_get() already does. Addressing a single list is unchanged.
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.
Since 1.12 keeps local and central extra fields in separate lists, an extra
field index can no longer address both at once: the index is applied to each
list in turn and the first match wins, so fields behind that match are skipped.
With one local and two central fields of the same id:
The count reports three fields, but the first central one is not reachable at
any index, and index 1 returns a valid pointer to a different field rather than
an error. Addressing one list at a time still finds all three.
zip_file_extra_field_get() got a guard for exactly this in cbad2ba. The by_id
variant was not changed, so this adds the same guard there. Addressing a single
list is unchanged.
I looked at the rest of the family before assuming it was wider: the two count
functions take no index, so both lists are unambiguous for them, and
zip_file_extra_field_set() with both flags writes the field to both lists,
which is lossless. Only this one function needed the guard.
The behaviour is on main only, so no released version is affected. I built with
BUILD_DOC=OFF because the documentation step writes generated files back into
the source tree, which I mount read-only.