1
0
mirror of https://github.com/php/php-src.git synced 2026-04-10 09:33:06 +02:00
Commit Graph

1235 Commits

Author SHA1 Message Date
Tim Düsterhus
f2e8c5da90 unserialize: Strictly check for :{ at object start (#10214)
* unserialize: Strictly check for `:{` at object start

* unserialize: Update CVE tests

It's unlikely that the object syntax error contributed to the actual CVE. The
CVE is rather caused by the incorrect object serialization data of the `C`
format. Add a second string without such a syntax error to ensure that path is
still executed as well to ensure the CVE is absent.

* Fix test expectation in gmp/tests/bug74670.phpt

No changes to the input required, because the test actually is intended to
verify the behavior for a missing `}`, it's just that the report position changed.

* NEWS

* UPGRADING
2023-01-12 19:55:54 +01:00
George Peter Banyard
334d108a2e Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10011 (Trampoline autoloader will get reregistered and cannot be unregistered)
2022-12-02 12:48:41 +00:00
George Peter Banyard
608ddb0321 Fix GH-10011 (Trampoline autoloader will get reregistered and cannot be unregistered)
There are two issues to resolve:
 1. The FCC is not refetch when trying to unregister a trampoline
 2. Comparing the function pointer of trampolines is meaningless as they are reallocated, thus we need to compare the name of the function

Found while working on GH-8294

Closes GH-10033
2022-12-02 12:47:25 +00:00
George Peter Banyard
6e87485d3c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-9883  SplFileObject::__toString() reads next line
2022-11-22 12:26:03 +00:00
George Peter Banyard
6fbf81c674 Fix GH-9883 SplFileObject::__toString() reads next line
We need to overwrite the __toString magic method for SplFileObject, similarly to how DirectoryIterator overwrites it
Moreover, the custom cast handler is useless as we define __toString methods, so use the standard one instead.

Closes GH-9912
2022-11-22 12:21:14 +00:00
Nikita Popov
70ad93dd6e Fix serialization of empty SplFixedArray
Avoid null pointer deref.
2022-09-15 22:36:19 +02:00
Tyson Andre
8b9679e88e Make var_export/debug_zval_dump check for infinite recursion on the *object* (#9448)
Switch the recursion check from the result of `get_properties_for`
(the returned hash table of properties) to just checking for
infinite recursion on the object.

- In order for a native datastructure to correctly implement
  `*get_properties_for` for var_export's cycle detection,
  it would need to return the exact same array every time prior to this PR.

  Prior to this commit, the requirements for cycle detection
  would prevent SplFixedArray or similar classes from returning a
  temporary array that:

  1. Wouldn't be affected by unexpected mutations from error handlers
  2. Could be garbage collected instead.
2022-08-30 09:19:45 -04:00
Máté Kocsis
adb45a63c0 Fix GH-9186 @strict-properties can be bypassed using unserialization (#9354)
* Emit deprecation warnings when adding dynamic properties to classes during unserialization - this will become an Error in php 9.0.
  (Adding dynamic properties in other contexts was already a deprecation warning - the use case of unserialization was overlooked)
* Throw an error when attempting to add a dynamic property to a `readonly` class when unserializing
* Add new serialization methods `__serialize`/`__unserialize` for SplFixedArray to avoid creating deprecated dynamic
  properties that would then be added to the backing fixed-size array
* Don't add named dynamic/declared properties (e.g. $obj->foo) of SplFixedArray to the backing array when unserializing
* Update tests to declare properties or to expect the deprecation warning
* Add news entry

Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
2022-08-30 07:46:32 -04:00
Christoph M. Becker
a1f5c8a587 Fix GH-9227: Trailing dots and spaces in filenames are ignored
Given that Windows ignores trailing dots and spaces in filenames, we
catch that ourselves to avoid confusion with the respective filenames
without these characters.

Closes GH-9229.
2022-08-19 14:23:57 +02:00
George Peter Banyard
7ab22aad9e Refactor code handling file.current_zval (#8934)
The Zval is always an array
2022-07-28 19:36:30 +01:00
Jakub Zelenka
1a9e6895f1 Fix #65069: GlobIterator incorrect handling of open_basedir check
This PR changes the glob stream wrapper so it impacts "glob://"
streamsas well. The idea is to do a check for each found path instead
of the pattern which was not working correctly.
2022-07-28 11:42:42 +01:00
Christoph M. Becker
5d52d472ef Fix #69181: READ_CSV|DROP_NEW_LINE drops newlines within fields
One may argue that `DROP_NEW_LINE` does not make sense in combination
with `READ_CSV`, but without `DROP_NEW_LINE`, `SKIP_EMPTY` does not
skip empty lines at all.  We could fix that, but do not for BC reasons.
Instead we no longer drop newlines in `spl_filesystem_file_read_ex()`
when reading CSV, but handle that in `spl_filesystem_file_read_csv()`
by treating lines with only (CR)LF as being empty as well.

Closes GH-7618.
2022-07-26 18:33:57 +02:00
Ilija Tovilo
5c10aa43c2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix spl test cleanup
2022-07-21 17:21:18 +02:00
Ilija Tovilo
3962f00b01 Fix spl test cleanup 2022-07-21 17:20:30 +02:00
Ilija Tovilo
b5ab0e06b8 Assert all test files are cleaned up in CI (#8977)
Closes GH-8427
2022-07-21 16:06:14 +01:00
Tim Düsterhus
7ae7df5b46 RFC: Make the iterator_*() family accept all iterables (#8819)
https://wiki.php.net/rfc/iterator_xyz_accept_array
2022-07-19 16:46:32 +02:00
George Peter Banyard
6f26102bbf Merge branch 'PHP-8.1'
* PHP-8.1:
  Revert "Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject"
  Revert "Update FreeBSD CI image."
2022-07-05 21:45:13 +01:00
George Peter Banyard
e67336f46a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Revert "Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject"
2022-07-05 21:33:47 +01:00
George Peter Banyard
79a283240e Revert "Fix GH-8563 Different results for seek() on SplFileObject and SplTempFileObject"
Although the fix is partially correct it also breaks long standing behaviour which has been produced since PHP 5.3.

This reverts commit 6f87a5c633.
2022-07-05 21:28:59 +01:00
George Peter Banyard
9bae9ab3a4 Fix GH-8861: correctly handle string lengths in SplFileinfo methods (#8869)
* Fix GH-8861: correctly handle string lengths in \SplFileinfo::getBasename

Co-authored-by: M. Vondano <m-vo@users.noreply.github.com>
2022-06-28 15:42:59 +01:00
cmp
6bd0175173 Prevent fclose on underlying SplFileObject file stream. (#7920) 2022-06-20 13:37:59 +01:00
George Peter Banyard
8c50b8d797 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject
2022-06-20 12:53:26 +01:00
George Peter Banyard
080fde2605 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8563  Different results for seek() on SplFileObject and SplTempFileObject
2022-06-20 12:53:01 +01:00
George Peter Banyard
6f87a5c633 Fix GH-8563 Different results for seek() on SplFileObject and SplTempFileObject
With memory streams if we get a NULL buffer we must not instantiate an empty line
2022-06-20 12:47:37 +01:00
George Peter Banyard
dbf1cafd77 Remove internal usage of SplFileInfo::_bad_state_ex() method (#8318)
* Use standard VM handling instead
 * Deprecate the method as it is now useless
2022-06-09 13:24:58 +01:00
George Peter Banyard
f800c60f13 Merge branch 'PHP-8.0' into PHP-8.1 2022-06-08 11:43:22 +01:00
George Peter Banyard
52eb52d652 Backport fcba0a49fc
Forgot this file exists in lower branches
2022-06-08 11:43:12 +01:00
George Peter Banyard
fcba0a49fc Fix test file name to not include a whitespace
This breaks the preload file flag in the test runner
2022-05-31 11:28:01 +01:00
George Peter Banyard
fc799ecdbe Move SplFileObject tests into subfolder 2022-05-27 18:33:48 +01:00
George Peter Banyard
cf51d8ffe7 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-8273: SplFileObject: key() returns wrong value
2022-04-23 14:02:01 +01:00
George Peter Banyard
660ef91fbc Fix GH-8273: SplFileObject: key() returns wrong value 2022-04-23 14:00:11 +01:00
George Peter Banyard
6186ecd436 Fix GH-8273: SplFileObject: key() returns wrong value 2022-04-23 13:56:38 +01:00
Marco Pivetta
25cb9cdb79 Fix GH-8232 - always reference classes in var_export() via their FQCN
Closes GH-8233

This fix corrects a behavior of `var_export()` that was mostly "hidden" until PHP 8.1 introduced:

* properties with object initializers
* constants containing object references
* default values of class properties containing `enum`s

Since `var_export(..., true)` is mostly used in conjunction with code generation,
and we cannot make assumptions about the generated code being placed in the root
namespace, we must always provide the FQCN of a class in exported code.

For example:

```php
<?php

namespace MyNamespace { class Foo {} }

namespace { echo "<?php\n\nnamespace Example;\n\n" . var_export(new \MyNamespace\Foo(), true) . ';'; }
```

produces:

```php
<?php

namespace Example;

MyNamespace\Foo::__set_state(array(
));
```

This code snippet is invalid, because `Example\MyNamespace\Foo::__set_state()` (which
does not exist) is called.

With this patch applied, the code looks like following (valid):

```php
<?php

namespace Example;

\MyNamespace\Foo::__set_state(array(
));
```

Ref: https://github.com/php/php-src/issues/8232
Ref: https://github.com/Ocramius/ProxyManager/issues/754
Ref: https://externals.io/message/117466
2022-04-23 11:06:21 +02:00
Christoph M. Becker
3de0ccfe09 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-8366: ArrayIterator may leak when calling __construct()
2022-04-15 19:10:29 +02:00
Christoph M. Becker
549cf3a24d Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8366: ArrayIterator may leak when calling __construct()
2022-04-15 19:08:28 +02:00
Christoph M. Becker
1762a87932 Fix GH-8366: ArrayIterator may leak when calling __construct()
When we detach an iterator, we also have to delete it.

Closes GH-8374.
2022-04-15 19:05:18 +02:00
George Peter Banyard
8dbfb15f7c Use more specific return types in SPL 2022-04-11 14:04:37 +01:00
George Peter Banyard
2ac5948f5c Refactor SplFileObject CSV methods (#8317)
Use early returns, which fixes ValueError order of arguments and flattens the code
2022-04-08 20:16:26 +01:00
Christoph M. Becker
634b2141de Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-8121: SplFileObject - seek and key with csv file inconsistent
2022-03-08 16:59:19 +01:00
Christoph M. Becker
3a71fcf5ca Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8121: SplFileObject - seek and key with csv file inconsistent
2022-03-08 16:57:58 +01:00
Christoph M. Becker
1d9a1f9be3 Fix GH-8121: SplFileObject - seek and key with csv file inconsistent
First, we must not free the current line before we call
`spl_filesystem_file_read_csv()`, because then the `current_line` will
not be properly updated.  Since the EOF check is superfluous here, we
move that part of the code to the branch for subtypes.  This issue has
been introduced by the fix for bug 75917.

Second, we only must increase the `current_line` if we're not reading
ahead.  This issue has been introduced by the fix for bug 62004.

Closes GH-8138.
2022-03-08 16:54:02 +01:00
Tyson Andre
b50315e73c Merge branch 'PHP-8.1'
Conflicts:
	ext/spl/tests/fixedarray_023.phpt
	ext/spl/spl_fixedarray.c (fix compile error)
2022-02-23 19:52:59 -05:00
Tyson Andre
5d907dfcee Merge branch 'PHP-8.0' into PHP-8.1 2022-02-23 19:26:24 -05:00
Tyson Andre
cd1c6f0b81 Fixes infinite recursion introduced by patch to SplFixedArray (#8105)
Closes GH-8079

Track whether the spl_fixedarray was modified since the last call to
get_properties
2022-02-23 19:23:00 -05:00
Dmitry Stogov
c77bbcd464 Fixed GH-8041 (php 8.2.0-dev crashes with assertion for cloning/get_object_vars on non-empty SplFixedArray) 2022-02-11 16:46:12 +03:00
Dmitry Stogov
a04d181578 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray)
2022-02-11 15:36:09 +03:00
Dmitry Stogov
a584d12667 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray)
2022-02-11 15:35:57 +03:00
Dmitry Stogov
52ae6417ca Fixed GH-8044 (var_export/debug_zval_dump HT_ASSERT_RC1 debug failure for SplFixedArray) 2022-02-11 15:33:31 +03:00
Christoph M. Becker
8683d17619 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7809: Cloning a faked SplFileInfo object may segfault
2021-12-23 23:15:02 +01:00
Christoph M. Becker
0ed39ed809 Fix GH-7809: Cloning a faked SplFileInfo object may segfault
While the `path` is not supposed to be `NULL` for normal operation, it
is possible to create `SplFileInfo` objects where that is the case, and
we must not follow the null pointer.

Closes GH-7814.
2021-12-23 23:10:51 +01:00