Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 767605a49793312fb6f3c0ff75d702e6d61cad91
Ticket: 451571ffffffffffffffffffffffffffffffffff
glob -directory -join bug in VFS
User & Date: nobody on 2001-08-21 01:07:56
Changes

  1. icomment:
    Logged In: NO 
    
    I've found the problem -- the bug actually existed in 8.3 
    but was only exercised due to FS overhaul.  I'll commit the 
    fixes (to Win/Mac too) when I commit some other FS 
    changes.  In the meantime, if you want a fix, replace the 
    appropriate block of code in tclUnixFile.c with this:
    
        if (types != NULL) {
    struct stat buf;
    
    if (types->perm != 0) {
        if (TclpStat(fname, &buf) != 0) {
    /* 
     * Either the file has disappeared 
    between the
     * 'readdir' call and 
    the 'TclpStat' call, or
     * the file is a link to a file 
    which doesn't
     * exist (which we could ascertain 
    with
     * TclpLstat), or there is some 
    other strange
     * problem.  In all these cases, we 
    define this
     * to mean the file does not match 
    any defined
     * permission, and therefore it is 
    not 
     * added to the list of files to 
    return.
     */
    typeOk = 0;
        }
        
        /* 
         * readonly means that there are NO 
    write permissions
         * (even for user), but execute is OK 
    for anybody
         */
        if (typeOk && (
    ((types->perm & 
    TCL_GLOB_PERM_RONLY) &&
    (buf.st_mode & 
    (S_IWOTH|S_IWGRP|S_IWUSR))) ||
    ((types->perm & TCL_GLOB_PERM_R) &&
    (TclpAccess(fname, R_OK) != 
    0)) ||
    ((types->perm & TCL_GLOB_PERM_W) &&
    (TclpAccess(fname, W_OK) != 
    0)) ||
    ((types->perm & TCL_GLOB_PERM_X) &&
    (TclpAccess(fname, X_OK) != 
    0))
    )) {
    typeOk = 0;
        }
    }
    if (typeOk && (types->type != 0)) {
        if (types->perm == 0) {
    /* We haven't yet done a stat on 
    the file */
    if (TclpStat(fname, &buf) != 0) {
        /* Posix error occurred */
        typeOk = 0;
    }
        }
        if (typeOk) {
    /*
     * In order bcdpfls as in 'find -t'
     */
    if (
        ((types->type & 
    TCL_GLOB_TYPE_BLOCK) &&
        S_ISBLK(buf.st_mode)) ||
        ((types->type & 
    TCL_GLOB_TYPE_CHAR) &&
        S_ISCHR(buf.st_mode)) ||
        ((types->type & 
    TCL_GLOB_TYPE_DIR) &&
        S_ISDIR(buf.st_mode)) ||
        ((types->type & 
    TCL_GLOB_TYPE_PIPE) &&
        S_ISFIFO(buf.st_mode)) 
    ||
        ((types->type & 
    TCL_GLOB_TYPE_FILE) &&
        S_ISREG(buf.st_mode))
    #ifdef S_ISSOCK
        || ((types->type & 
    TCL_GLOB_TYPE_SOCK) &&
        S_ISSOCK(buf.st_mode))
    #endif
        ) {
        /* Do nothing -- this file is 
    ok */
    } else {
        typeOk = 0;
    #ifdef S_ISLNK
        if (types->type & 
    TCL_GLOB_TYPE_LINK) {
    if (TclpLstat(fname, &buf) 
    == 0) {
        if (S_ISLNK
    (buf.st_mode)) {
            typeOk = 1;
        }
    }
        }
    #endif
    }
        }
    }
        }
    
    
    
  2. login: "nobody"
  3. mimetype: "text/plain"
  4. username: "nobody"