]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
tar: free two temporary allocated strings after use (#2255)
authorMartin Matuška <martin@matuska.org>
Thu, 4 Jul 2024 22:56:52 +0000 (00:56 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Jul 2024 22:56:52 +0000 (15:56 -0700)
OSS-Fuzz issue: 70020

libarchive/archive_read_support_format_tar.c

index 3b7bd8556c19e86e99414fed5ebb7b7a1fd30b6c..5a19872b20eedd649c752fab7a6f0e5fe36834ca 100644 (file)
@@ -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);