From 31e277b35e399cb21dfa15c782f09e293ed4b5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 20 Mar 2023 21:34:21 +0100 Subject: [PATCH] Wrap return value of archive_write_data_block(3) archive_write_data_block(3) might depending on the version of libarchive on success return 0 or the number of bytes written. `archive_write_data_block` however always expects 0 on success. See man:archive_write_data(3) --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 306aa68..25554b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -573,7 +573,13 @@ fn libarchive_copy_data( } archive_result( - ffi::archive_write_data_block(archive_writer, buffer, size, offset) as i32, + /* Might depending on the version of libarchive on success + * return 0 or the number of bytes written, + * see man:archive_write_data(3) */ + match ffi::archive_write_data_block(archive_writer, buffer, size, offset) { + x if x >= 0 => 0, + x => i32::try_from(x).unwrap(), + }, archive_writer, )?; }