diff options
Diffstat (limited to 'ext/phar/phar_object.c')
-rw-r--r-- | ext/phar/phar_object.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 388087720a..ab62ff398a 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -3614,7 +3614,8 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, size_t file char *error; size_t contents_len; phar_entry_data *data; - php_stream *contents_file; + php_stream *contents_file = NULL; + php_stream_statbuf ssb; if (filename_len >= sizeof(".phar")-1) { start_pos = ('/' == filename[0] ? 1 : 0); /* account for any leading slash: multiple-leads handled elsewhere */ @@ -3651,10 +3652,20 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, size_t file } php_stream_copy_to_stream_ex(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len); } - data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len; } + if (contents_file != NULL && php_stream_stat(contents_file, &ssb TSRMLS_CC) != -1) { + data->internal_file->flags = ssb.sb.st_mode & PHAR_ENT_PERM_MASK ; + } else { +#ifndef _WIN32 + mode_t mask; + mask = umask(0); + umask(mask); + data->internal_file->flags &= ~mask; +#endif + } + /* check for copy-on-write */ if (pphar[0] != data->phar) { *pphar = data->phar; |