Skip to content

copy the caller buffer before in-place moves in zip_files_move#443

Merged
kuba-- merged 1 commit into
kuba--:masterfrom
jmestwa-coder:stream-delete-caller-buffer-inplace
Jul 16, 2026
Merged

copy the caller buffer before in-place moves in zip_files_move#443
kuba-- merged 1 commit into
kuba--:masterfrom
jmestwa-coder:stream-delete-caller-buffer-inplace

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

In-memory delete mode shifts surviving entry data straight through the caller-owned stream buffer:

  • zip_stream_open(..., 'd') aliases the caller's buffer as m_pMem with m_mem_capacity 0
  • zip_entries_delete -> zip_files_move -> zip_mem_move memmoves onto m_pMem to compact, before any write_func call
  • the copy-on-write only guards the write/central-dir path, so this shift is unprotected

On a read-only backing (const/.rodata/PROT_READ mmap) that memmove is a write-through-const fault; on a writable buffer it silently mutates the caller's original bytes. Copy into a library-owned block on the first move, matching zip_stream_delete_write_func, so zip_stream_close frees it. Added test_entries_delete_stream_buffer_untouched (fails on master, passes here).

@kuba--
kuba-- merged commit 000943f into kuba--:master Jul 16, 2026
18 checks passed
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