Blame SOURCES/0002-libarchive-Handle-archive_entry_symlink-returning-NU.patch

7a9a56
From e5b45f861a4d5738679f37d46ebca6e171bb3212 Mon Sep 17 00:00:00 2001
7a9a56
From: Colin Walters <walters@verbum.org>
7a9a56
Date: Mon, 4 Apr 2022 10:25:35 -0400
7a9a56
Subject: [PATCH 2/6] libarchive: Handle `archive_entry_symlink()` returning
7a9a56
 NULL
7a9a56
7a9a56
The `archive_entry_symlink()` API can definitely return `NULL`,
7a9a56
reading through the libarchive sources.
7a9a56
7a9a56
I hit this in the wild when using old ostree-ext to try to unpack
7a9a56
a chunked archive.
7a9a56
7a9a56
I didn't try to characterize this more, and sorry no unit test right
7a9a56
now.
7a9a56
---
7a9a56
 src/libostree/ostree-repo-libarchive.c | 8 ++++++--
7a9a56
 1 file changed, 6 insertions(+), 2 deletions(-)
7a9a56
7a9a56
diff --git a/src/libostree/ostree-repo-libarchive.c b/src/libostree/ostree-repo-libarchive.c
7a9a56
index 679aa44d..631c6d4b 100644
7a9a56
--- a/src/libostree/ostree-repo-libarchive.c
7a9a56
+++ b/src/libostree/ostree-repo-libarchive.c
7a9a56
@@ -146,8 +146,12 @@ file_info_from_archive_entry (struct archive_entry *entry)
7a9a56
 
7a9a56
   g_autoptr(GFileInfo) info = _ostree_stbuf_to_gfileinfo (&stbuf);
7a9a56
   if (S_ISLNK (stbuf.st_mode))
7a9a56
-    g_file_info_set_attribute_byte_string (info, "standard::symlink-target",
7a9a56
-                                           archive_entry_symlink (entry));
7a9a56
+    {
7a9a56
+      const char *target = archive_entry_symlink (entry);
7a9a56
+      if (target != NULL)
7a9a56
+        g_file_info_set_attribute_byte_string (info, "standard::symlink-target",
7a9a56
+                                               target);
7a9a56
+    }
7a9a56
 
7a9a56
   return g_steal_pointer (&info;;
7a9a56
 }
7a9a56
-- 
7a9a56
2.31.1
7a9a56