Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On close, handle short writes from archive_write_callback #1530

Merged
merged 1 commit into from May 27, 2021

Conversation

owtaylor
Copy link
Contributor

The archive_write_callback passed to archive_write_open() is documented as:

"each call to the write callback function should translate to a single write(2) system call.
On success, the write callback should return the number of bytes actually written"

And in most places, the code repeatedly calls the write callback, but when flushing
the buffer at close, the write callback was called once, assuming it would write everything.
This could result in a truncated archive.

A test is added to test short writes in different code paths.

@kientzle
Copy link
Contributor

Nice! Please remember to add your new file to the top-level Makefile.am and libarchive/tests/CMakeLists.txt.

The archive_write_callback passed to archive_write_open() is documented as:

 "each call to the write callback function should translate to a single write(2) system call.
  On success, the write callback should return the number of bytes actually written"

And in most places, the code repeatedly calls the write callback, but when flushing
the buffer at close, the write callback was called once, assuming it would write everything.
This could result in a truncated archive.

A test is added to test short writes in different code paths.
@owtaylor
Copy link
Contributor Author

Please remember to add your new file to the top-level Makefile.am and libarchive/tests/CMakeLists.txt.

Sorry for forgetting to add it to Makefile.am - new version pushed with that fixed.

@mmatuska mmatuska merged commit 4649d6e into libarchive:master May 27, 2021
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.

None yet

3 participants