]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Fix error checking in writing files 2672/head
authorRose <gfunni234@gmail.com>
Wed, 11 Jun 2025 19:21:46 +0000 (15:21 -0400)
committerRose <gfunni234@gmail.com>
Fri, 20 Jun 2025 17:55:57 +0000 (13:55 -0400)
commitfd4ecc01469d9c7d7b7c19ac2a176b13b54a202a
tree3e4ae159018c5483a30df2aa7ac7e3203743324b
parenta218a52dbba98ff4071105207ff9275efff3eabe
Fix error checking in writing files

For write, 0 may not mean an error at all. We need to instead check for the length not being the same.

With fwrite, because 0 could mean an error, but not always. We must check that we wrote the entire file!

Note that unlike write, fwrite's description according to POSIX does not mention returning a negative type at all. Nor does it say you can retry unlike write.

Finally, with write, we need to check less than 0, not 0, as 0 is a valid return and does not mean an error.
libarchive/archive_check_magic.c
libarchive/archive_write_open_fd.c
libarchive/archive_write_open_file.c
libarchive/archive_write_open_filename.c