]> git.ipfire.org Git - thirdparty/libarchive.git/commit
On close, handle short writes from archive_write_callback 1530/head
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 12 May 2021 20:26:24 +0000 (16:26 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Fri, 14 May 2021 14:13:40 +0000 (10:13 -0400)
commit3bc9bfc04e000f476a0634f18d640d9e9407e021
tree31b5919a923ac9c313a4988647abbbc439d2094c
parent942cd1a5e1ce4e1450cecafa2674f71aea0263a4
On close, handle short writes from archive_write_callback

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.
Makefile.am
libarchive/archive_write.c
libarchive/test/CMakeLists.txt
libarchive/test/test_short_writes.c [new file with mode: 0644]