[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.

--- mc-2006-11-14-16/src/utilunix.c.tmpcrash	2005-07-27 17:03:25.000000000 +0200
+++ mc-2006-11-14-16/src/utilunix.c	2006-11-27 10:32:54.000000000 +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/";

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