Skip to content

Fix source error handling across reopen - #555

Closed
carrerasdarren-cell wants to merge 1 commit into
nih-at:mainfrom
carrerasdarren-cell:fix/source-reopen-state
Closed

Fix source error handling across reopen#555
carrerasdarren-cell wants to merge 1 commit into
nih-at:mainfrom
carrerasdarren-cell:fix/source-reopen-state

Conversation

@carrerasdarren-cell

@carrerasdarren-cell carrerasdarren-cell commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #552 and bf51731.

This PR originally covered two reopen regressions. Upstream commit 4cd7310 has now adopted the lookahead reset from this PR; this refresh rebases on current main and keeps regression coverage for it.

The remaining functional changes are:

  • zip_source_close() no longer queries ZIP_SOURCE_ERROR after a callback returned success. Callback failures are already captured when they return -1; querying after success can resurrect an error from an earlier open cycle.
  • The WinZip AES source explicitly reports deferred integrity failures from ZIP_SOURCE_CLOSE, clears its private error on reopen, and releases its crypto context on close. These changes preserve HMAC error propagation after removing the unconditional error query and avoid leaking the prior context across a partial-read reopen.

Regression coverage includes the lookahead case fixed by 4cd7310 and the still-distinct stale-error case. On current unmodified main plus the regression test, the latter fails with closing reopened source failed: Invalid argument; this patch passes it.

Validation:

  • ctest --test-dir build -R "^exact-read-integrity\\.test$" --output-on-failure: passed.
  • ctest --test-dir build --parallel 4 --output-on-failure: 187/187 passed.
  • The prior AppVeyor build passed all x64 and Win32 jobs. Its two ARM jobs failed before project configuration because the runner lacks the selected Windows ARM SDK; current upstream main build 1.0.1028 fails in the same jobs for the same reason.

dillof added a commit that referenced this pull request Jul 22, 2026
Do not query ZIP_SOURCE_ERROR after a successful close callback. Callback failures are already captured when they return -1; querying after success can resurrect an error from an earlier open cycle.

Make the WinZip AES source report deferred integrity failures from close, clear its private error on reopen, and release its crypto context on close.

Keep regression coverage for the lookahead reset now landed in 4cd7310 from nih-at#555, plus the still-distinct stale-error reopen case.
@carrerasdarren-cell carrerasdarren-cell changed the title Fix source state handling across reopen Fix source error handling across reopen Jul 23, 2026
@dillof dillof closed this in 385a0c4 Aug 5, 2026
@dillof

dillof commented Aug 5, 2026

Copy link
Copy Markdown
Member

Thanks for the bug report and test program.

We found a solution that more closely resembles how errors are handled in other zip_source functions: Only propagate the error from the source if it returns -1.

Your extended tests pass with our change.

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.

2 participants