Commit graph

703 commits

Author SHA1 Message Date
Ilija Tovilo
78ec64af44
Fix use-of-uninitialized value in phar_object.c
resource would stay uninitialized if the first call to zend_parse_parameters
fails, but the value is still passed to phar_add_file(). It's not used there if
cont_str is provided and so didn't cause any issues.

Closes GH-11202
2023-05-08 17:06:44 +02:00
Niels Dossche
347b7c3628
Fix wrong flags check for compression method in phar_object.c
I found this issue using static analysis tools, it reported that the condition was always false.
We can see that flags is assigned in the switch statement above, but a mistake was made in the comparison.

Closes GH-10328

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-15 15:35:35 +00:00
Stanislav Malyshev
18ebe1588d
Merge branch 'PHP-8.0'
* PHP-8.0:
  Update NEWS
  Fix #81211: Symlinks are followed when creating PHAR archive
2021-08-23 23:31:00 -07:00
Stanislav Malyshev
33e4174d1c
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update NEWS
  Fix #81211: Symlinks are followed when creating PHAR archive
2021-08-23 23:30:34 -07:00
Stanislav Malyshev
40db8947e2
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update NEWS
  Fix #81211: Symlinks are followed when creating PHAR archive
2021-08-23 23:29:01 -07:00
Christoph M. Becker
2ff853aa11
Fix #81211: Symlinks are followed when creating PHAR archive
It is insufficient to check whether the `base` is contained in `fname`;
we also need to ensure that `fname` is properly separated.  And of
course, `fname` has to start with `base`.
2021-08-23 23:25:16 -07:00
Remi Collet
c51af22fef
implement openssl_256 and openssl_512 for phar singatures 2021-08-11 14:13:57 +02:00
Nikita Popov
edb6b375dd Don't return bool from Phar::offsetUnset()
This violates the ArrayAccess interface. Use offsetExists() to
check if an entry exists.
2021-07-16 16:39:27 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Máté Kocsis
83916e83b4
Declare tentative return types for ext/phar (#7052) 2021-05-28 15:07:15 +02:00
Máté Kocsis
0224cc83fc
Merge branch 'PHP-8.0'
* Add a few missing RETURN_THROWS();
* Fix a few ext/phar return types
2021-05-27 16:32:16 +02:00
Máté Kocsis
2d47447d66 Add a few missing RETURN_THROWS();
Only PharFileInfo::compress() really needs it though.
2021-05-27 16:31:18 +02:00
Nikita Popov
f57526a07a Store base path as zend_string in Phar::buildFrom*
This also removes the need to check for length overflow, as the
length is now size_t.
2021-05-27 10:57:51 +02:00
Nikita Popov
8c192c717c Accept regex as zend_string in Phar::buildFromDirectory()
No need to copy it...
2021-05-27 10:51:51 +02:00
George Peter Banyard
e7135cb817
Use zend_string_equals_* API in a couple of more place
Closes GH-6979
2021-05-14 13:45:17 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Dmitry Stogov
13e4ce386b Improve SPL directory and stat() cache using zend_srting* instead of char* 2021-02-26 02:28:46 +03:00
Máté Kocsis
5b5bfd6be4
Generate class entries from stubs for phar, posix, pspell, readline, reflection, session, shmop
Closes GH-6692
2021-02-15 00:11:22 +01:00
Nikita Popov
ccc70ec5d4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make Phar $fileNotFoundScript nullable
2021-02-09 12:57:58 +01:00
Nikita Popov
44192ce80b Make Phar $fileNotFoundScript nullable
While "" is already treated the same way as absence, null is the
logically correct default here. Making this one argument non-nullable
is particularly pecular when considering that the preceding $alias
and $index arguments are both nullable.
2021-02-09 12:55:33 +01:00
Christoph M. Becker
e1a1918f26 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
2021-01-19 10:31:06 +01:00
Christoph M. Becker
cfae999f1b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
2021-01-19 10:30:28 +01:00
Christoph M. Becker
68f5289e9e Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
When extracting compressed files from an uncompressed Phar, we must not
use the direct file pointer, but rather get an uncompressed file
pointer.

We also add a test to show that deflated and stored entries are
properly extracted.

This also fixes #79912, which appears to be a duplicate of #69279.

Co-authored-by: Anna Filina <afilina@gmail.com>

Closes GH-6599.
2021-01-19 10:28:54 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Christoph M. Becker
afc69e46b8 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix memory leak in Phar::webPhar() on Windows
2021-01-05 14:25:44 +01:00
Christoph M. Becker
5c963731e2 Fix memory leak in Phar::webPhar() on Windows
Closes GH-6574.
2021-01-05 14:21:35 +01:00
Nikita Popov
ad7e231e81 Make compression_type nullable in a few more places
Missed that this was also used elsewhere...
2020-10-08 17:05:38 +02:00
Nikita Popov
9719d6cade Make Phar $format and $compression arguments nullable
Rather than using Greg's birthday, use null to indicate that the
existing format/compression should be retained. For the format
simply using zero would be sufficient, but as the documentation
explicitly says that NULL is allowed here, we may as well make
that the truth.
2020-10-08 13:12:22 +02:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Máté Kocsis
628db3f3b5
Fix UNKNOWN default values in various extensions
Closes GH-6075
2020-09-07 19:02:02 +02:00
Máté Kocsis
be5ba20132
Promote warnings to exceptions in ext/phar
Closes GH-6008
2020-08-25 11:57:37 +02:00
Máté Kocsis
046cc5e4c2
Add another round of missing parameter types to stubs
Closes GH-5950
2020-08-07 16:48:45 +02:00
Máté Kocsis
7b9f37c389
Fix ZPP order in ext/phar 2020-08-07 16:47:50 +02:00
Tyson Andre
0c238ede01 [RFC] Only unserialize Phar metadata when getMetadata() is called
In other words, don't automatically unserialize when the magic
phar:// stream wrappers are used.
RFC: https://wiki.php.net/rfc/phar_stop_autoloading_metadata

Also, change the signature from `getMetadata()`
to `getMetadata(array $unserialize_options = [])`.
Start throwing earlier if setMetadata() is called and serialization threw.

See https://externals.io/message/110856 and
https://bugs.php.net/bug.php?id=76774

This was refactored to add a phar_metadata_tracker for the following reasons:
- The way to properly copy a zval was previously implicit and undocumented
  (e.g. is it a pointer to a raw string or an actual value)
- Avoid unnecessary serialization and unserialization in the most common case
- If a metadata value is serialized once while saving a new/modified phar file,
  this allows reusing the same serialized string.
- Have as few ways to copy/clone/lazily parse metadata (etc.) as possible,
  so that code changes can be limited to only a few places in the future.
- Performance is hopefully not a concern - copying a string should be faster
  than unserializing a value, and metadata should be rare in most cases.

Remove unnecessary skip in a test(Compression's unused)

Add additional assertions about usage of persistent phars

Improve robustness of `Phar*->setMetadata()`

- Add sanity checks for edge cases freeing metadata, when destructors
  or serializers modify the phar recursively.
- Typical use cases of php have phar.readonly=1 and would not be affected.

Closes GH-5855
2020-08-03 13:28:51 -04:00
Nikita Popov
2160f5ce59 Call zpp_none in PharFileInfo::__destruct()
Using __destruct() with internal classes is dubious, but not so
simple to avoid here because the code extends SPL classes.
2020-07-21 10:18:33 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
785497c8ba Fix leaks in Phar::webPhar() 2020-06-25 15:42:56 +02:00
Nikita Popov
15846ff115 Add ZVAL_OBJ_COPY macro
For the common ZVAL_OBJ + GC_ADDREF pattern.
This mirrors the existing ZVAL_STR_COPY API.
2020-06-17 16:36:56 +02:00
Nikita Popov
257dbb0450 Add zend_call_known_function() API family
This adds the following APIs:

void zend_call_known_function(
    zend_function *fn, zend_object *object, zend_class_entry *called_scope,
    zval *retval_ptr, int param_count, zval *params);

void zend_call_known_instance_method(
    zend_function *fn, zend_object *object, zval *retval_ptr, int param_count, zval *params);
void zend_call_known_instance_method_with_0_params(
    zend_function *fn, zend_object *object, zval *retval_ptr);
void zend_call_known_instance_method_with_1_params(
    zend_function *fn, zend_object *object, zval *retval_ptr, zval *param);
void zend_call_known_instance_method_with_2_params(
    zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2);

These are used to perform a call if you already have the
zend_function you want to call. zend_call_known_function()
is the base API, the rest are just really thin wrappers around
it for the common case of instance method calls.

Closes GH-5692.
2020-06-09 16:21:54 +02:00
twosee
88355dd338 Constify char * arguments of APIs
Closes GH-5676.
2020-06-08 10:38:45 +02:00
George Peter Banyard
3092a1ee12 Fix [-Wundef] warning in PHAR extension 2020-05-20 18:22:10 +02:00
Máté Kocsis
c6485535c2
Generate method entries from stubs for curl, ffi, pdo, phar
Closes GH-5375
2020-04-14 11:49:02 +02:00
Christoph M. Becker
7248341ea6 Fix # 79171: heap-buffer-overflow in phar_extract_file
We must not access memory outside of the allocated buffer.
2020-02-17 00:20:31 -08:00
Stanislav Malyshev
bcbc053dc1 Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions 2020-02-17 00:20:31 -08:00
Christoph M. Becker
b01b1f65e7 Fix # 79171: heap-buffer-overflow in phar_extract_file
We must not access memory outside of the allocated buffer.
2020-02-17 00:20:17 -08:00
Stanislav Malyshev
bbcb8cab8c Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions 2020-02-17 00:20:17 -08:00
Christoph M. Becker
7df594b943 Fix # 79171: heap-buffer-overflow in phar_extract_file
We must not access memory outside of the allocated buffer.
2020-02-17 00:20:04 -08:00
Stanislav Malyshev
6facfa59a5 Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions 2020-02-17 00:19:30 -08:00