Skip to content

Reject window stat past lower source end - #567

Open
carrerasdarren-cell wants to merge 1 commit into
nih-at:mainfrom
carrerasdarren-cell:fix-window-stat-past-end
Open

Reject window stat past lower source end#567
carrerasdarren-cell wants to merge 1 commit into
nih-at:mainfrom
carrerasdarren-cell:fix-window-stat-past-end

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown
Contributor

Summary

  • reject an unknown-length window whose start exceeds the lower source size during zip_source_stat()
  • prevent the unsigned subtraction from reporting ZIP_UINT64_MAX (or another wrapped size)
  • add a public-API regression covering the out-of-range start

Before this change, a one-byte buffer wrapped with zip_source_window_create(base, 2, -1, ...) reported a size of 18446744073709551615. File-backed sources already reject the equivalent range with ZIP_ER_INVAL; the window source now does the same when its lower source exposes a size.

Verification

  • built the library with CMake
  • compiled and ran regress/programs/source_seek.c directly
  • repeated the focused regression under AddressSanitizer and UndefinedBehaviorSanitizer

For unknown-length windows, subtracting a start beyond the lower source size wrapped the reported zip_uint64_t size. Return ZIP_ER_INVAL and cover the public API path with a regression test.

Assisted-by: OpenAI Codex
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