[PATCH] mc crashes when temporary directory cannot be created
Hi all, there is a breakage in util.c and utilunix.c related to temporary files creation. The problem is that if a directory for temporary files cannot be created mc ends up in infinite loop caused by: tmpbase = concat_dir_and_file (mc_tmpdir (), prefix); in mc_mkstemps() which then calls mc_tmpdir() back infinitely and ends up in a stack underflow. The attached patch fixes it as it disables the creation of the temporary files when the temp. directory couldn't be created. Cheers, Jindrich --- mc-2006-11-14-16/src/utilunix.c.tmpcrash 2005-07-27 17:03:25.0 +0200 +++ mc-2006-11-14-16/src/utilunix.c 2006-11-27 10:32:54.0 +0100 @@ -274,9 +274,12 @@ /* Need to create directory */ if (mkdir (buffer, S_IRWXU) != 0) { fprintf (stderr, - _(Cannot create temporary directory %s: %s\n), - buffer, unix_error_string (errno)); - error = ; + _(Cannot create temporary directory %s: %s\n%s%s\n), + buffer, unix_error_string (errno), + _(Temporary files will not be created\n), + _(Press any key to continue...)); + getc (stdin); + return /dev/null/; } } ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [PATCH] mc crashes when temporary directory cannot be created
Hello Jindrich, On Mon, 27 Nov 2006, Jindrich Novy wrote: there is a breakage in util.c and utilunix.c related to temporary files creation. The problem is that if a directory for temporary files cannot be created mc ends up in infinite loop caused by: tmpbase = concat_dir_and_file (mc_tmpdir (), prefix); in mc_mkstemps() which then calls mc_tmpdir() back infinitely and ends up in a stack underflow. The attached patch fixes it as it disables the creation of the temporary files when the temp. directory couldn't be created. Ok. But... what happens if any of the following error conditions occur ? if (lstat (buffer, st) == 0) { /* Sanity check for existing directory */ if (!S_ISDIR (st.st_mode)) error = _(%s is not a directory\n); else if (st.st_uid != getuid ()) error = _(Directory %s is not owned by you\n); else if (((st.st_mode 0777) != 0700) (chmod (buffer, 0700) != 0)) error = _(Cannot set correct permissions for directory %s\n); } else { Wouldn't it cause the same loop as when mkdir() fails ? ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel