summaryrefslogtreecommitdiff
blob: abfc494f0c13d73dc3e859f9052c49d572290ab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Fix insecure tempfile usage

Patch by Tavis Ormandy

http://bugs.gentoo.org/104565

--- gtkdiskfree-1.9.3/src/mount.c
+++ gtkdiskfree-1.9.3/src/mount.c
@@ -31,41 +31,21 @@
 void
 open_cmd_tube (const gchar *cmd, const gchar *mount_point)
 {
-	gint status;
-	gchar error[MAXLINE], *line;
-	FILE *sh, *tmp;
+	gchar error[MAXLINE], *line, *status;
+	FILE *sh;
 	
 	setbuf(stdout, error);
-	line = g_strconcat(cmd, " ", mount_point, " &> ", TUBE_NAME, NULL);
+	line = g_strconcat(cmd, " ", mount_point, " 2>&1", NULL);
 	sh = popen(line, "r");
 	g_free(line);
 	
-	status = pclose(sh);
-	
-	if (status == 0) {
-		remove(TUBE_NAME);
-		gui_list_main_update(GTK_TREE_VIEW(list_treeview));
-		
-		return;
-	} else {
-		if ((tmp = fopen(TUBE_NAME, "r")) == NULL) {
-			gui_list_main_update(GTK_TREE_VIEW(list_treeview)); 
-			
-			return;
-		}
-		if (fgets(error, MAXLINE-1, tmp) == NULL) {
-			fclose(tmp);
-			remove(TUBE_NAME);
-			gui_list_main_update(GTK_TREE_VIEW(list_treeview));
-			
-			return;
-		}
-		fclose(tmp);
-		remove(TUBE_NAME);
+	status = fgets(error, MAXLINE-1, sh);
+
+	if (status && (pclose(sh) != 0))
 		error_window(error);
-	}
+
 	gui_list_main_update(GTK_TREE_VIEW(list_treeview));
-	
+
 	return;
 }