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 ?



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