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

[PATCH] "gconfig" removed root folder...


Hi,

This new patch includes Muli's remarks.
Need to be applied against a 2.6.1 kernel.

Thanks, Romain.
==========================[ cut here]==========================
diff -Naur linux-2.6.1/scripts/kconfig/gconf.c linux/scripts/kconfig/gconf.c
--- linux-2.6.1/scripts/kconfig/gconf.c	2004-01-15 21:45:22.000000000 +0100
+++ linux/scripts/kconfig/gconf.c	2004-01-21 20:48:04.000000000 +0100
@@ -23,6 +23,9 @@
 #include <unistd.h>
 #include <time.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 
 //#define DEBUG
 
@@ -643,14 +646,29 @@
 store_filename(GtkFileSelection * file_selector, gpointer user_data)
 {
 	const gchar *fn;
+	gchar trailing;
+	gchar *safe_fn;
+	struct stat sb;
 
-	fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
+	fn = gtk_file_selection_get_filename (GTK_FILE_SELECTION
 					     (user_data));
 
-	if (conf_write(fn))
-		text_insert_msg("Error", "Unable to save configuration !");
+	/* protect against 'root directory' bug */
+	trailing = fn[strlen (fn)-1];
+	safe_fn = g_strdup (fn);
+
+	if(!stat (fn, &sb))
+		if (S_ISDIR(sb.st_mode))
+			if (trailing != '/')
+			{
+				g_free (safe_fn);
+				safe_fn = g_strconcat (fn, "/", NULL);
+			}
 
-	gtk_widget_destroy(GTK_WIDGET(user_data));
+	if (conf_write (safe_fn))
+		text_insert_msg("Error", "Unable to save configuration !");
+	g_free (safe_fn);
+	gtk_widget_destroy (GTK_WIDGET(user_data));
 }
 
 void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)

-- 
Romain Li鐃叙in (roms):         <roms _at_ tilp.info>
Web site:                     http://tilp.info
"Linux, y'a moins bien mais c'est plus cher !"






-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo _at_ vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


この情報があなたの探していたものかどうか選択してください。
yes/まさにこれだ!   no/違うなぁ   part/一部見つかった   try/これで試してみる

あなたが探していた情報はどのようなことか、ご自由に記入下さい。特に「まさにこれだ!」と言う場合は記入をお願いします。
例:「複数のマシンからCATV経由でipmasqueradeを利用してWebを参照したい場合の設定について」
References: