From e7b2ab7aebc91bdcbec47043ab30c44e3723473e Mon Sep 17 00:00:00 2001 From: AtariDreams <83477269+AtariDreams@users.noreply.github.com> Date: Fri, 21 Jul 2023 22:30:44 -0400 Subject: [PATCH] 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. --- libarchive/archive_write_disk_posix.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 { -- 2.47.2