From: Martin Matuška Date: Thu, 4 Jul 2024 22:56:52 +0000 (+0200) Subject: tar: free two temporary allocated strings after use (#2255) X-Git-Tag: v3.7.5~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5e5efe13a0e1ce9f9d8f6e3c4d4964dac52323b;p=thirdparty%2Flibarchive.git tar: free two temporary allocated strings after use (#2255) OSS-Fuzz issue: 70020 --- diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 3b7bd8556..5a19872b2 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -1349,9 +1349,12 @@ header_common(struct archive_read *a, struct tar *tar, archive_strlen(&linkpath), tar->sconv) != 0) { err = set_conversion_failed_error(a, tar->sconv, "Linkname"); - if (err == ARCHIVE_FATAL) + if (err == ARCHIVE_FATAL) { + archive_string_free(&linkpath); return (err); + } } + archive_string_free(&linkpath); } /* * The following may seem odd, but: Technically, tar @@ -1422,9 +1425,12 @@ header_common(struct archive_read *a, struct tar *tar, archive_strlen(&linkpath), tar->sconv) != 0) { err = set_conversion_failed_error(a, tar->sconv, "Linkname"); - if (err == ARCHIVE_FATAL) + if (err == ARCHIVE_FATAL) { + archive_string_free(&linkpath); return (err); + } } + archive_string_free(&linkpath); } archive_entry_set_filetype(entry, AE_IFLNK); archive_entry_set_size(entry, 0);