1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00

fix edge case where a new phar is created via mkdir(), add to dir.phpt test

This commit is contained in:
Greg Beaver
2008-04-14 15:21:41 +00:00
parent ef552c57de
commit 2277396fe3
3 changed files with 6 additions and 3 deletions

View File

@@ -2045,7 +2045,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
offset += 4 + entry->filename_len + sizeof(entry_buffer) + entry->metadata_str.len + (entry->is_dir ? 1 : 0);
/* compress and rehash as necessary */
if (oldfile && !entry->is_modified) {
if ((oldfile && !entry->is_modified) || entry->is_dir) {
continue;
}
if (!phar_get_efp(entry TSRMLS_CC)) {
@@ -2302,7 +2302,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
if (zend_hash_get_current_data(&phar->manifest, (void **)&entry) == FAILURE) {
continue;
}
if (entry->is_deleted) {
if (entry->is_deleted || entry->is_dir) {
continue;
}
if (entry->cfp) {

View File

@@ -31,11 +31,13 @@ var_dump(file_exists($pname3 . '/another/dir/'));
ini_set('phar.readonly', 1);
mkdir($pname . '/fails');
ini_set('phar.readonly', 0);
mkdir('phar://oops.phar/fails');
// create new phar by mkdir
mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails');
?>
===DONE===
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
<?php unlink(dirname(__FILE__) . '/ok.phar'); ?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php'); ?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
--EXPECTF--

View File

@@ -471,6 +471,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
if (entry->is_dir) {
*ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
(*ret)->position = 0;
(*ret)->fp = NULL;
(*ret)->phar = phar;
(*ret)->for_write = for_write;
(*ret)->internal_file = entry;