[gnome-autoar/wip/oholy/various-fixes: 3/17] extractor: Prevent creation of unrelated directories




commit c1289703ec96aaee4e2d3007ab8e80385a90abb7
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Feb 19 09:30:42 2021 +0100

    extractor: Prevent creation of unrelated directories
    
    `g_file_make_directory_with_parents` is called to create `self->destination_dir`
    directory before extraction. However, the files may be written to completely
    different dir later if the they have common prefix and the prefix is consequently
    changed over `decide-destination` signal. Let's use `self->prefix_new` if it is
    set to prevent creation of unrelated directories.

 gnome-autoar/autoar-extractor.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index 4841ef0..13bf5b9 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -1906,19 +1906,18 @@ autoar_extractor_step_decide_destination (AutoarExtractor *self)
     }
   }
 
-  destination_name = g_file_get_path (self->new_prefix != NULL ?
-                                      self->new_prefix :
-                                      self->destination_dir);
+  new_destination = (self->new_prefix != NULL) ? self->new_prefix : self->destination_dir;
+  destination_name = g_file_get_path (new_destination);
   g_debug ("autoar_extractor_step_decide_destination: destination %s", destination_name);
 
-  g_file_make_directory_with_parents (self->destination_dir,
+  g_file_make_directory_with_parents (new_destination,
                                       self->cancellable,
                                       &(self->error));
 
   if (g_error_matches (self->error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
     GFileType file_type;
 
-    file_type = g_file_query_file_type (self->destination_dir,
+    file_type = g_file_query_file_type (new_destination,
                                         G_FILE_QUERY_INFO_NONE,
                                         NULL);
 


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