mcedit leaks file handler if safe save set
- From: "Andrew V. Samoilov" <kai cmail ru>
- To: awn bcs zp ua, GNU Midnight Commander Development Team <mc-devel gnome org>, Pavel Roskin <proski gnu org>
- Subject: mcedit leaks file handler if safe save set
- Date: Fri, 21 Dec 2001 11:31:43 +0200
Hi, Pavel!
There is unpleasant bug in mc's builtin editor since 4.5.55
found by Andrew W. Nosenko <awn bcs zp ua>.
mc_mkstemps use pure open system call to create temporary file
and thus this file handle must be closed by pure close system call.
As far as I understand mc_mkstemps was written for local fs, but:
* it is used in edit/editcmd.c/edit_save_file() to generate filename
for safe save.
* without temporary hack below mc leaks file handlers and
this/these file(s) cannot be unlinked or executed.
BTW, Andrew W. Nosenko reported undelfs is not large file compatible.
There are atol is used in some places for ino_t.
Best regards,
Andrew.
P.S. Andrew, my previous solution was wrong. Roll it back, please,
and use this patch temporarily, please.
P.P.S. I am going on buziness trip for a week, so I probably will be
offline after 16.00 GMT today.
--- editcmd.c Mon Nov 26 13:20:56 2001
+++ /home/sav/src/mc/edit/editcmd.c Fri Dec 21 11:06:36 2001
@@ -201,20 +201,27 @@ int edit_save_file (WEdit * edit, const
if (this_save_mode > 0) {
char *savedir, *slashpos, *saveprefix;
- savedir = (char *) strdup (".");
- slashpos = strrchr (filename, '/');
+ slashpos = strrchr (filename, PATH_SEP);
if (slashpos) {
- free (savedir);
savedir = (char *) strdup (filename);
savedir[slashpos - filename + 1] = '\0';
- }
+ } else
+ savedir = (char *) strdup (".");
saveprefix = concat_dir_and_file (savedir, "cooledit");
free (savedir);
fd = mc_mkstemps(&savename, saveprefix, NULL);
g_free (saveprefix);
if (!savename)
return 0;
+/*
+ * FIXME: mc_mkstemps use pure open system call to create temporary file...
+ * This file handle must be close()d, but there is next line in edit.h:
+ * #define close mc_close
+ * So this hack needed.
+ */
+#undef close
close (fd);
+#define close mc_close
} else
savename = g_strdup (filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]