From: Greg Beaver Date: Sun, 6 Jan 2008 05:28:27 +0000 (+0000) Subject: eliminated memleak, now to make it recognize "dir" as a directory X-Git-Tag: RELEASE_2_0_0a1~1008 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=826e98be8329d29bb136319cd6ab131650cd8814;p=php eliminated memleak, now to make it recognize "dir" as a directory --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 7f628e4041..735198d85e 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2225,11 +2225,13 @@ static php_url* phar_open_url(php_stream_wrapper *wrapper, char *filename, char return NULL; } if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len TSRMLS_CC) == FAILURE) { - if (arch && !entry) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch); - arch = NULL; - } else { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\" (cannot contain .phar.php and .phar.gz/.phar.bz2)", filename); + if (!(options & PHP_STREAM_URL_STAT_QUIET)) { + if (arch && !entry) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch); + arch = NULL; + } else { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\" (cannot contain .phar.php and .phar.gz/.phar.bz2)", filename); + } } if (arch) { efree(arch); @@ -4012,7 +4014,7 @@ static void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stre int tmp_len; memset(ssb, 0, sizeof(php_stream_statbuf)); - if (!is_dir) { + if (!is_dir && !data->is_dir) { ssb->sb.st_size = data->uncompressed_filesize; ssb->sb.st_mode = data->flags & PHAR_ENT_PERM_MASK; ssb->sb.st_mode |= S_IFREG; /* regular file */ @@ -4119,7 +4121,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, uint host_len; int retval; - if ((resource = phar_open_url(wrapper, url, "r", 0 TSRMLS_CC)) == NULL) { + if ((resource = phar_open_url(wrapper, url, "r", flags TSRMLS_CC)) == NULL) { return -1; } diff --git a/ext/phar/tests/tar/tar_003.phpt b/ext/phar/tests/tar/tar_003.phpt index d4a98432fa..d4b287978d 100644 --- a/ext/phar/tests/tar/tar_003.phpt +++ b/ext/phar/tests/tar/tar_003.phpt @@ -23,7 +23,7 @@ fclose($g); echo file_get_contents($pname . '/internal/file/here'); $a = opendir($pname . '/'); while (false !== ($v = readdir($a))) { - echo (is_file($pname . $v) ? "file\n" : "dir\n"); + echo (is_file($pname . '/' . $v) ? "file\n" : "dir\n"); echo $v . "\n"; } closedir($a);