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

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
@carrerasdarren-cell

Copy link
Copy Markdown
Contributor Author

CI note: AppVeyor build 1.0.1062 completed 6 of 8 matrix jobs successfully. The only failures were the ARM and ARM/UWP jobs, both during toolchain setup before libzip configured: the image lacks Windows SDK 10.0.26100.0 for Desktop C++ ARM Apps, and vcpkg consequently cannot configure bzip2/its compiler probe. Current main and unrelated PRs fail in the same two jobs, so this is an AppVeyor image issue rather than a patch failure. The focused source-window regression passes locally, including under ASan/UBSan.

This branch has not been deployed

No deployments
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