[file-roller] fixed extraction of cpio archives with absolute paths



commit 0fd2638893557d47b4e3b34c505f966bfd471fdc
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Aug 26 10:40:21 2010 +0200

    fixed extraction of cpio archives with absolute paths
    
    [bug #558023]

 src/fr-archive.c      |    3 +++
 src/fr-command-cpio.c |   13 ++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 741b478..1e79812 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -2812,7 +2812,9 @@ compute_base_path (const char *base_dir,
 			new_path = g_strdup (file_name_from_path (path));
 		else
 			new_path = g_strdup (path);
+
 		/*debug (DEBUG_INFO, "%s, %s --> %s\n", base_dir, path, new_path);*/
+
 		return new_path;
 	}
 
@@ -2853,6 +2855,7 @@ compute_list_base_path (const char *base_dir,
 	for (scan = filtered; scan; scan = scan->next) {
 		const char *path = scan->data;
 		char       *new_path;
+
 		new_path = compute_base_path (base_dir, path, junk_paths, can_junk_paths);
 		if (new_path != NULL)
 			list = g_list_prepend (list, new_path);
diff --git a/src/fr-command-cpio.c b/src/fr-command-cpio.c
index 0f5219b..feeaad7 100644
--- a/src/fr-command-cpio.c
+++ b/src/fr-command-cpio.c
@@ -199,12 +199,19 @@ fr_command_cpio_extract (FrCommand *comm,
                 fr_process_set_working_dir (comm->process, dest_dir);
 	fr_process_add_arg (comm->process, "-c");
 	
-	cmd = g_string_new ("cpio -idu ");
+	cmd = g_string_new ("cpio -idu --no-absolute-filenames ");
 	for (scan = file_list; scan; scan = scan->next) {
-		char *filename = g_shell_quote (scan->data);
+		char *filepath = scan->data;
+		char *filename;
+
+		if (filepath[0] == '/')
+			filename = g_shell_quote (filepath + 1);
+		else
+			filename = g_shell_quote (filepath);
 		g_string_append (cmd, filename);
-		g_free (filename);
 		g_string_append (cmd, " ");
+
+		g_free (filename);
 	}
         g_string_append (cmd, " < ");
 	g_string_append (cmd, comm->e_filename);



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