Changeset 661 in svn for trunk/xcache.c


Ignore:
Timestamp:
2009-08-03T09:37:21+02:00 (6 years ago)
Author:
Xuefer
Message:

fix stat() for relative file not in include_path but in current executing file directory (only for when inode available)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r656 r661  
    814814    int size = strlen(include_path) + 1;
    815815    char tokens[] = { DEFAULT_DIR_SEPARATOR, '\0' };
     816    int ret;
    816817    ALLOCA_FLAG(use_heap)
    817818
     
    820821
    821822    for (path = php_strtok_r(paths, tokens, &tokbuf); path; path = php_strtok_r(NULL, tokens, &tokbuf)) {
    822         if (snprintf(filepath, sizeof(filepath), "%s/%s", path, filename) >= MAXPATHLEN - 1) {
    823             continue;
    824         }
    825         if (VCWD_STAT(filepath, pbuf) == 0) {
    826             my_free_alloca(paths, use_heap);
    827             return SUCCESS;
    828         }
    829     }
    830 
     823        if (snprintf(filepath, sizeof(filepath), "%s/%s", path, filename) < MAXPATHLEN - 1) {
     824            if (VCWD_STAT(filepath, pbuf) == 0) {
     825                ret = SUCCESS;
     826                goto finish;
     827            }
     828        }
     829    }
     830
     831    /* fall back to current directory */
     832    if (zend_is_executing(TSRMLS_C)) {
     833        char *path = zend_get_executed_filename(TSRMLS_C);
     834        if (path && path[0] != '[') {
     835            int len = strlen(path);
     836            while ((--len >= 0) && !IS_SLASH(path[len])) {
     837                /* skipped */
     838            }
     839            if (len > 0 && len + strlen(filename) + 1 < MAXPATHLEN - 1) {
     840                strcpy(filepath, path);
     841                strcpy(filepath + len + 1, filename);
     842                if (VCWD_STAT(filepath, pbuf) == 0) {
     843                    ret = SUCCESS;
     844                    goto finish;
     845                }
     846            }
     847        }
     848    }
     849
     850    ret = FAILURE;
     851
     852finish:
    831853    my_free_alloca(paths, use_heap);
    832854
    833     return FAILURE;
     855    return ret;
    834856}
    835857/* }}} */
Note: See TracChangeset for help on using the changeset viewer.