Re: gtk 1.2 and 2.0 file selector when / is not readable
- From: Frederic Crozat <fcrozat mandrakesoft com>
- To: Gtk Hackers <gtk-devel-list gnome org>
- Subject: Re: gtk 1.2 and 2.0 file selector when / is not readable
- Date: 11 Sep 2002 15:59:24 +0200
Le mar 10/09/2002 à 19:11, Frederic Crozat a écrit :
> Hi all,
>
> while fixing remaining bugs for Mandrake 9.0, I've discovered a "nice"
> in GTK+ File Selector for both 1.2 and 2.0 :
>
> as root, just do chmod o-r /
>
> as a normal user, create a temporary directory (mkdir foobar), go to
> this directory (cd foobar), start a gtk application which use
> gtkfileselector (for instead gedit)
>
> while this application is running, remove the directory and try to open
> file selector => gtk starts a infinite loop which try to eat all
> available memory (well, OOM kills it..)
>
> We are seeing this on all Mandrake system using High Security
> restrictions, aka msec 4 (or 5).
Another test case it to use a non readable current directory with / not
readable..
The following patches try to fix the problem by fallbacking to home dir
if "/" is not readable and exiting if home dir is not readable (or
available)..
--
Frederic Crozat
MandrakeSoft
--- gtk+-1.2.10/gtk/gtkfilesel.c.fileselectorfallback 2002-09-11 11:25:27.000000000 +0200
+++ gtk+-1.2.10/gtk/gtkfilesel.c 2002-09-11 13:05:39.000000000 +0200
@@ -1578,6 +1578,7 @@
{
gchar getcwd_buf[2*MAXPATHLEN];
CompletionState *new_state;
+ gint fallback = 0;
new_state = g_new (CompletionState, 1);
@@ -1594,6 +1595,7 @@
* a root directory, right? Right? (Probably not portable to non-Unix)
*/
strcpy (getcwd_buf, "/");
+ fallback = 1;
}
tryagain:
@@ -1616,7 +1618,26 @@
if (!new_state->reference_dir)
{
/* Directories changing from underneath us, grumble */
- strcpy (getcwd_buf, "/");
+ if (fallback == 0) {
+ strcpy (getcwd_buf, "/");
+ fallback = 1;
+ }
+ else {
+ if (fallback == 1) { /* last try with user home dir */
+ if (g_get_home_dir ()) {
+ strcpy (getcwd_buf, g_get_home_dir ());
+ }
+ fallback = 2;
+ }
+ else {
+ g_error ("no readable fallback directory found for GtkFileSelector, exiting");
+ }
+ }
+ /* don't leak updated_text and the_completion.text */
+ if (new_state->the_completion.text)
+ g_free (new_state->the_completion.text);
+ if (new_state->updated_text)
+ g_free (new_state->updated_text);
goto tryagain;
}
--- gtk+-2.0.6/gtk/gtkfilesel.c.orig 2002-06-16 06:02:28.000000000 +0200
+++ gtk+-2.0.6/gtk/gtkfilesel.c 2002-09-11 13:24:08.000000000 +0200
@@ -2533,6 +2533,7 @@
gchar *sys_getcwd_buf;
gchar *utf8_cwd;
CompletionState *new_state;
+ gint fallback = 0;
new_state = g_new (CompletionState, 1);
@@ -2560,8 +2561,29 @@
if (!new_state->reference_dir)
{
+ /* don't leak updated_text and the_completion.text */
+ if (new_state->the_completion.text)
+ g_free (new_state->the_completion.text);
+ if (new_state->updated_text)
+ g_free (new_state->updated_text);
/* Directories changing from underneath us, grumble */
- strcpy (utf8_cwd, G_DIR_SEPARATOR_S);
+ if (fallback == 0) {
+ if (utf8_cwd) {
+ g_free (utf8_cwd);
+ }
+ utf8_cwd = g_strdup (G_DIR_SEPARATOR_S);
+ fallback = 1;
+ }
+ else {
+ if (fallback == 1) { /* last try with user home dir */
+ g_free (utf8_cwd);
+ utf8_cwd = g_filename_to_utf8 (g_get_home_dir (), -1, NULL, NULL, NULL);
+ fallback = 2;
+ }
+ else {
+ g_error ("no readable fallback directory found for GtkFileSelector, exiting");
+ }
+ }
goto tryagain;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]