From: AtariDreams <83477269+AtariDreams@users.noreply.github.com> Date: Sat, 22 Jul 2023 02:30:44 +0000 (-0400) Subject: return ((int)r); is not part of if statement due to missing brackets (#1930) X-Git-Tag: v3.7.1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7b2ab7aebc91bdcbec47043ab30c44e3723473e;p=thirdparty%2Flibarchive.git return ((int)r); is not part of if statement due to missing brackets (#1930) This is problematic because we need to return if an error occurs, and because we are letting a continue to be evaluated even though it is closed. --- diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index f28aaefdc..c8c2e1058 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -1611,12 +1611,12 @@ hfs_write_data_block(struct archive_write_disk *a, const char *buff, "Seek failed"); return (ARCHIVE_FATAL); } else if (a->offset > a->fd_offset) { - int64_t skip = a->offset - a->fd_offset; + uint64_t skip = a->offset - a->fd_offset; char nullblock[1024]; memset(nullblock, 0, sizeof(nullblock)); while (skip > 0) { - if (skip > (int64_t)sizeof(nullblock)) + if (skip > sizeof(nullblock)) bytes_written = hfs_write_decmpfs_block( a, nullblock, sizeof(nullblock)); else @@ -1731,9 +1731,10 @@ _archive_write_disk_finish_entry(struct archive *_a) else r = hfs_write_data_block( a, null_d, a->file_remaining_bytes); - if (r < 0) + if (r < 0) { close_file_descriptor(a); return ((int)r); + } } #endif } else {