1
From bac5d03a29a411c79e0d838d48c404900d30066d Mon Sep 17 00:00:00 2001
2
From: Paolo Bacchilega <paobac@src.gnome.org>
3
Date: Fri, 25 Jun 2010 10:45:32 +0000
4
Subject: [rar] fixed seg fault when there is an extra info line in the output
7
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
8
index 482ab57..2c42ba4 100644
9
--- a/src/fr-command-rar.c
10
+++ b/src/fr-command-rar.c
11
@@ -117,6 +117,59 @@ process_line (char *line,
15
+ if (! rar_comm->odd_line) {
18
+ fdata = rar_comm->fdata;
20
+ /* read file info. */
22
+ fields = split_line (line, 6);
23
+ if (g_strv_length (fields) < 6) {
24
+ /* wrong line format, treat this line as a filename line */
25
+ g_strfreev (fields);
26
+ file_data_free (rar_comm->fdata);
27
+ rar_comm->fdata = NULL;
28
+ rar_comm->odd_line = TRUE;
31
+ if ((strcmp (fields[2], "<->") == 0)
32
+ || (strcmp (fields[2], "<--") == 0))
34
+ /* ignore files that span more volumes */
36
+ file_data_free (rar_comm->fdata);
37
+ rar_comm->fdata = NULL;
40
+ fdata->size = g_ascii_strtoull (fields[0], NULL, 10);
41
+ fdata->modified = mktime_from_string (fields[3], fields[4]);
43
+ if ((fields[5][1] == 'D') || (fields[5][0] == 'd')) {
46
+ tmp = fdata->full_path;
47
+ fdata->full_path = g_strconcat (fdata->full_path, "/", NULL);
49
+ fdata->original_path = g_strdup (fdata->original_path);
50
+ fdata->free_original_path = TRUE;
54
+ fdata->name = dir_name_from_path (fdata->full_path);
58
+ fdata->name = g_strdup (file_name_from_path (fdata->full_path));
60
+ fr_command_add_file (comm, fdata);
61
+ rar_comm->fdata = NULL;
64
+ g_strfreev (fields);
68
if (rar_comm->odd_line) {
71
@@ -141,48 +194,7 @@ process_line (char *line,
72
fdata->path = remove_level_from_path (fdata->full_path);
77
- fdata = rar_comm->fdata;
79
- /* read file info. */
81
- fields = split_line (line, 6);
83
- if ((strcmp (fields[2], "<->") == 0)
84
- || (strcmp (fields[2], "<--") == 0))
86
- /* ignore files that span more volumes */
88
- file_data_free (rar_comm->fdata);
89
- rar_comm->fdata = NULL;
92
- fdata->size = g_ascii_strtoull (fields[0], NULL, 10);
93
- fdata->modified = mktime_from_string (fields[3], fields[4]);
95
- if ((fields[5][1] == 'D') || (fields[5][0] == 'd')) {
98
- tmp = fdata->full_path;
99
- fdata->full_path = g_strconcat (fdata->full_path, "/", NULL);
101
- fdata->original_path = g_strdup (fdata->original_path);
102
- fdata->free_original_path = TRUE;
106
- fdata->name = dir_name_from_path (fdata->full_path);
110
- fdata->name = g_strdup (file_name_from_path (fdata->full_path));
112
- fr_command_add_file (comm, fdata);
113
- rar_comm->fdata = NULL;
116
- g_strfreev (fields);
119
rar_comm->odd_line = ! rar_comm->odd_line;