[gnome-autoar/wip/oholy/extractor-symlink-regression] extractor: Fix extraction in symlinked locations




commit 8626035793abe4bab4f30b2c4a306e28f34c4041
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Oct 8 09:33:11 2021 +0200

    extractor: Fix extraction in symlinked locations
    
    The "The file is not a directory" error is returned in case the archive has
    common prefix, which have not been changed over the `decide-destination`
    signal and the destination is a symlink. This is regression caused by the
    commit b9590ab7. It causes that the security checks, which was added by the
    commit 8109c368, verifies also the destination directory by mistake. Let's
    partially rework the problematic commit to avoid this regression.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/36

 gnome-autoar/autoar-extractor.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index 0c4be32..eb3edda 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -907,7 +907,8 @@ autoar_extractor_do_sanitize_pathname (AutoarExtractor *self,
     extracted_filename = g_file_get_child (destination, basename);
   }
 
-  if (self->prefix != NULL && self->new_prefix != NULL) {
+  if (self->prefix != NULL && self->new_prefix != NULL &&
+      !g_file_equal (self->prefix, self->new_prefix)) {
     g_autofree char *relative_path;
     /* Replace the old prefix with the new one */
     relative_path = g_file_get_relative_path (self->prefix,
@@ -1829,11 +1830,6 @@ autoar_extractor_step_decide_destination (AutoarExtractor *self)
                                                 self->prefix,
                                                 files,
                                                 &self->new_prefix);
-
-    if (self->new_prefix && g_file_equal (self->prefix, self->new_prefix)) {
-      /* This prevents redundant path name handling later. */
-      g_clear_object (&self->new_prefix);
-    }
   } else {
     autoar_extractor_signal_decide_destination (self,
                                                 self->destination_dir,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]