From alejandro.delcastillo@ni.com Wed Nov 20 22:35:01 2019 Return-Path: From: Alejandro del Castillo To: , CC: Alejandro del Castillo Subject: [opkg][PATCH 1/2] opkg_archive.c: avoid double free on uncompress error Date: Wed, 20 Nov 2019 16:34:47 -0600 Message-ID: <20191120223448.26522-2-alejandro.delcastillo@ni.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20191120223448.26522-1-alejandro.delcastillo@ni.com> References: <20191120223448.26522-1-alejandro.delcastillo@ni.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit The open-inner function calls archive_read_open. On error, archive_read_open calls inner_close, which also closes the outter archive. On error, return NULL directly to avoid double free. Upstream-Status: Backport Signed-off-by: Alejandro del Castillo --- libopkg/opkg_archive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libopkg/opkg_archive.c b/libopkg/opkg_archive.c index 3d87db1..0e9ccea 100644 --- a/libopkg/opkg_archive.c +++ b/libopkg/opkg_archive.c @@ -622,7 +622,7 @@ static struct archive *open_inner(struct archive *outer) if (r != ARCHIVE_OK) { opkg_msg(ERROR, "Failed to open inner archive: %s\n", archive_error_string(inner)); - goto err_cleanup; + return NULL; } return inner; @@ -683,7 +683,7 @@ static struct archive *extract_outer(const char *filename, const char *arname) inner = open_inner(outer); if (!inner) - goto err_cleanup; + return NULL; return inner; -- 2.22.0