From: Paul Barker Date: Sat, 26 Sep 2015 18:38:13 +0000 (+0100) Subject: Issue 578: Close temp_fd in 7zip and xar writers X-Git-Tag: v3.1.900a~32^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F607%2Fhead;p=thirdparty%2Flibarchive.git Issue 578: Close temp_fd in 7zip and xar writers The ISO9660 writer uses a temp_fd and closes it in the archive_free handler. The same logic is added to the archive_free handlers for the 7zip and xar writers. Signed-off-by: Paul Barker --- diff --git a/libarchive/archive_write_set_format_7zip.c b/libarchive/archive_write_set_format_7zip.c index 7847cb3c5..fc6ccfe0b 100644 --- a/libarchive/archive_write_set_format_7zip.c +++ b/libarchive/archive_write_set_format_7zip.c @@ -1450,6 +1450,10 @@ _7z_free(struct archive_write *a) { struct _7zip *zip = (struct _7zip *)a->format_data; + /* Close the temporary file. */ + if (zip->temp_fd >= 0) + close(zip->temp_fd); + file_free_register(zip); compression_end(&(a->archive), &(zip->stream)); free(zip->coder.props); diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index 4538befd9..a2dbc0399 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -1877,6 +1877,11 @@ xar_free(struct archive_write *a) struct xar *xar; xar = (struct xar *)a->format_data; + + /* Close the temporary file. */ + if (xar->temp_fd >= 0) + close(xar->temp_fd); + archive_string_free(&(xar->cur_dirstr)); archive_string_free(&(xar->tstr)); archive_string_free(&(xar->vstr));