[PATCH] mc crashes when temporary directory cannot be created
Jindrich Novy
jnovy at redhat.com
Tue Nov 28 12:21:56 UTC 2006
Hi Pavel,
On Mon, 2006-11-27 at 17:37 +0200, Pavel Tsekov wrote:
> 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 ?
Good point, I missed that. IMO only removal of the fallback will prevent
the infinite loop in any case as it shouldn't call mc_mkstemps() at all.
I'm sending patch for it.
Thoughts?
Jindrich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mc-tmpcrash.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20061128/ad585c7f/attachment.bin>
More information about the mc-devel
mailing list