Blame SOURCES/fix-use-after-free-in-delayed-newc.patch

006282
From 6a71cce7ed735f83f9a6a6bad8beaa47f8d14734 Mon Sep 17 00:00:00 2001
006282
From: Ondrej Dubaj <odubaj@redhat.com>
006282
Date: Mon, 27 May 2019 10:06:14 +0200
006282
Subject: [PATCH 1/2] Fix use-after-free in delayed link processing (newc
006282
 format)
006282
006282
During archiving, if some of the "delayed" hard link entries
006282
happened to disappear on filesystem (or become unreadable) for
006282
some reason (most probably race), the old code free()d the 'entry'
006282
and continued with the loop;  the next loop though dereferenced
006282
'entry' and crashed the archiver.
006282
006282
Per report from Coverity.
006282
---
006282
 tar/write.c | 9 ++++-----
006282
 1 file changed, 4 insertions(+), 5 deletions(-)
006282
006282
diff --git a/tar/write.c b/tar/write.c
006282
index 9c24566..3970de2 100644
006282
--- a/tar/write.c
006282
+++ b/tar/write.c
006282
@@ -540,8 +540,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
006282
 			lafe_warnc(archive_errno(disk),
006282
 			    "%s", archive_error_string(disk));
006282
 			bsdtar->return_value = 1;
006282
-			archive_entry_free(entry);
006282
-			continue;
006282
+			goto next_entry;
006282
 		}
006282
 
006282
 		/*
006282
@@ -559,13 +558,13 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
006282
 				bsdtar->return_value = 1;
006282
 			else
006282
 				archive_read_close(disk);
006282
-			archive_entry_free(entry);
006282
-			continue;
006282
+			goto next_entry;
006282
 		}
006282
 
006282
 		write_file(bsdtar, a, entry);
006282
-		archive_entry_free(entry);
006282
 		archive_read_close(disk);
006282
+next_entry:
006282
+		archive_entry_free(entry);
006282
 		entry = NULL;
006282
 		archive_entry_linkify(bsdtar->resolver, &entry, &sparse_entry);
006282
 	}
006282
-- 
006282
2.17.1
006282
006282
006282
From a999ca882aeb8fce4f4f2ee1317f528984b47e8e Mon Sep 17 00:00:00 2001
006282
From: Ondrej Dubaj <odubaj@redhat.com>
006282
Date: Mon, 27 May 2019 10:34:48 +0200
006282
Subject: [PATCH 2/2] call missing archive_read_close() in write_archive()
006282
006282
---
006282
 tar/write.c | 3 +--
006282
 1 file changed, 1 insertion(+), 2 deletions(-)
006282
006282
diff --git a/tar/write.c b/tar/write.c
006282
index 3970de2..63c619c 100644
006282
--- a/tar/write.c
006282
+++ b/tar/write.c
006282
@@ -556,8 +556,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
006282
 			    "%s", archive_error_string(disk));
006282
 			if (r == ARCHIVE_FATAL)
006282
 				bsdtar->return_value = 1;
006282
-			else
006282
-				archive_read_close(disk);
006282
+			archive_read_close(disk);
006282
 			goto next_entry;
006282
 		}
006282
 
006282
-- 
006282
2.17.1
006282