diff options
author | Stanislav Malyshev <stas@php.net> | 2018-12-01 21:07:05 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2018-12-01 21:08:38 -0800 |
commit | 67f3615102544a7a8704369df14c44ad27ce7cf7 (patch) | |
tree | ae8c1c963242f29221795e9cfdd1e3eea81bd109 /ext/phar/phar_object.c | |
parent | 87bf84c8c7224ac85de77f7552068d4fce8b95c4 (diff) | |
parent | 69f5e7992bfc239e42a3a82e290399ca75bc56a6 (diff) | |
download | php-git-67f3615102544a7a8704369df14c44ad27ce7cf7.tar.gz |
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
Fix bug #77022 - use file mode or umask for new files
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 bfbbd1479b..6259e4a766 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -3663,7 +3663,8 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam 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 && !memcmp(filename, ".phar", sizeof(".phar")-1) && (filename[5] == '/' || filename[5] == '\\' || filename[5] == '\0')) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create any files in magic \".phar\" directory", (*pphar)->fname); @@ -3697,10 +3698,20 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam } 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; |