Skip to content

Fix uint16 overflow in _zip_ef_size() extra field accumulator#522

Open
kodareef5 wants to merge 1 commit intonih-at:mainfrom
kodareef5:fix-ef-size-overflow
Open

Fix uint16 overflow in _zip_ef_size() extra field accumulator#522
kodareef5 wants to merge 1 commit intonih-at:mainfrom
kodareef5:fix-ef-size-overflow

Conversation

@kodareef5
Copy link
Copy Markdown

_zip_ef_size() at lib/zip_extra_field.c:309 accumulates extra field sizes into a zip_uint16_t. When the total exceeds 65535, the value wraps around silently. This is noted by the TODO: check for overflow comment at zip_dirent.c:1075.

Fix: accumulate into zip_uint32_t and cap the return value at ZIP_UINT16_MAX.

_zip_ef_size() accumulates extra field sizes into a zip_uint16_t.
When the total exceeds 65535, the value wraps around silently.
The developer acknowledged this at zip_dirent.c:1075 with a
"TODO: check for overflow" comment.

Fix by accumulating into zip_uint32_t and capping the return
value at ZIP_UINT16_MAX.
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