1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 02:02:32 +01:00
Commit Graph

2634 Commits

Author SHA1 Message Date
Niels Dossche
1cdcbc05b0 Fix GH-11972: RecursiveCallbackFilterIterator regression in 8.1.18
When you do an assignment between two zvals (no, not zval*), you copy
all fields. This includes the additional u2 data. So that means for
example the Z_NEXT index gets copied, which in some cases can therefore
cause a cycle in zend_hash lookups.
Instead of doing an assignment, we should be doing a ZVAL_COPY (or
ZVAL_COPY_VALUE for non-refcounting cases). This avoids copying u2.

Closes GH-12086.
2023-08-30 22:30:59 +02:00
Niels Dossche
b71c6b2c6c Fix #81992: SplFixedArray::setSize() causes use-after-free
Upon resizing, the elements are destroyed from lower index to higher
index. When an element refers to an object with a destructor, it can
refer to a lower (i.e. already destroyed) element, causing a uaf.
Set refcounted zvals to NULL after destroying them to avoid a uaf.

Closes GH-11959.
2023-08-14 21:32:22 +02:00
Niels Dossche
bce536067c Fix GH-11338: SplFileInfo empty getBasename with more than one slash
Regressed in 13e4ce386b.

Closes GH-11340.
2023-05-30 17:29:18 +02:00
nielsdos
81e50b4ee3 Fix GH-11178: Segmentation fault in spl_array_it_get_current_data (PHP 8.1.18)
Dynamic property case in zend_get_property_info() can return NULL for
prop info. This was not handled.

Closes GH-11182.
2023-05-03 19:42:04 +02:00
Ilija Tovilo
5855bdcd6c Fix reference returned from CallbackFilterIterator::accept()
Fixes oss-fuzz #58181
2023-04-20 10:18:18 +02:00
Ilija Tovilo
9aaa5cd093 By-ref modification of typed and readonly props through ArrayIterator
Fixes GH-10844
Closes GH-10872
2023-03-25 16:14:19 +01:00
NathanFreeman
49b2ff5dbb Fix GH-10519: Array Data Address Reference Issue
We need to carry around a reference to the underlying Bucket to be able to modify it by reference.

Closes GH-10749

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-03-10 14:23:30 +00:00
Niels Dossche
0801c567dc Fix GH-10248: Assertion `!(zval_get_type(&(*(property))) == 10)' failed.
The assertion failure was triggered in a debug code-path that validates
property types for internal classes.
zend_verify_internal_read_property_type was called with retval being a
reference, which is not allowed because that function eventually calls to
i_zend_check_property_type, which does not expect a reference.
The non-debug code-path already takes into account that retval can be a
reference, as it optionally dereferences retval.

Add a dereference in zend_verify_internal_read_property_type just before
the call to zend_verify_property_type, which is how other callers often
behave as well.
2023-01-20 16:40:15 +01: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
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
Dmitry Stogov
f7d0a3e0e0 Keep original EG(jit_trace_num) value around __autoload() 2022-09-29 15:00:52 +03: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
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
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
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
Christoph M. Becker
e004e1a93b Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8235: iterator_count() may run indefinitely
2022-05-03 12:59:39 +02:00
Christoph M. Becker
ad7b9f4e50 Fix GH-8235: iterator_count() may run indefinitely
We need to prevent integer overflow to eventually stop the iteration.

A test case doesn't appear sensible for this, because even on 32bit
architectures a respective test easily runs for a few minutes.

Closes GH-8447.
2022-05-03 12:57:58 +02: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
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
Nikita Popov
d0a0518798 Make DirectoryIterator current() / key() return types tentative
Fixes GH-8192.
2022-03-12 17:32:44 +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
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
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
Máté Kocsis
24be11f632 Remove bogus type of $object param in SplObjectStorage::offsetSet()
This parameter definitely only accepts objects, so we shouldn't explicitly
mark it as mixed. Looks like I accidentally added this type when adding
the tentative return type.

Closes GH-7840
2021-12-28 18:01:26 +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
Christoph M. Becker
6f325104eb Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #75917: SplFileObject::seek broken with CSV flags
2021-12-06 19:02:32 +01:00
Aliaksandr Bystry
daf79e2d91 Fix #75917: SplFileObject::seek broken with CSV flags
Closes GH-7697.
2021-12-06 18:59:48 +01:00
Remi Collet
ef2fd0e5b5 fix [-Wstrict-prototypes] buid warnings 2021-11-24 14:55:11 +01:00
Nikita Popov
d7ad32649a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed bug #81587
2021-11-04 10:38:08 +01:00
Nikita Popov
4b9fbc6627 Fixed bug #81587
iterator_funcs_ptr may be null for Iterators with custom
get_iterator. Ideally MultipleIterator would make use of get_iterator,
but this would require a large implementation change.
2021-11-04 10:34:52 +01:00
Christoph M. Becker
96ac919957 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
2021-09-29 16:18:36 +02:00
Christoph M. Becker
ee5711de33 Fix #81477: LimitIterator + SplFileObject regression in 8.0.1
We must not free the read line, if the `READ_AHEAD` flag is set.  This
also restores the expectations of SplFileObject_next_variation002.phpt.

Closes GH-7518.
2021-09-29 16:17:14 +02:00
Christoph M. Becker
e73cc7aea9 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:55:11 +02:00
Christoph M. Becker
6154aa652d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
2021-09-28 15:52:58 +02:00
Christoph M. Becker
2d6684091f Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
We address the `::setSize(0)` case by setting `array->element = NULL`
and `array->size = 0` before we destroy the elements.

Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>

Closes GH-7503.
2021-09-28 15:48:53 +02:00
Nikita Popov
eac65680ab Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix leak when iterating uninitialized RecursiveIteratorIterator
2021-09-24 13:18:00 +02:00
Nikita Popov
3adbafeef7 Fix leak when iterating uninitialized RecursiveIteratorIterator 2021-09-24 13:17:34 +02:00
Tyson Andre
27976d7dc7 Merge branch 'PHP-8.0' into PHP-8.1 2021-09-13 21:18:56 -04:00
Tyson Andre
753645a6f8 Merge remote-tracking branch 'origin/PHP-7.4' into PHP-8.0 2021-09-13 21:00:53 -04:00
Tyson Andre
b053192a03 Fix #81429: Handle resizing in SplFixedArray::offsetSet (#7487)
offsetSet did not account for the fact that the array may no longer exist after
the field is overwritten. This fixes that.

Add test of resizing both to the empty array and a smaller array - there should
be no valgrind warnings with a proper fix.

Alternate approach to #7486 (described in https://bugs.php.net/bug.php?id=81429)
2021-09-13 20:59:06 -04:00
Nikita Popov
5b2ddf5a17 Export zend_use_resource_as_offset()
Use a common implementation to generate this error message, as
we do so in quite a few places dealing with array keys.
2021-08-31 10:58:01 +02:00