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

140468 Commits

Author SHA1 Message Date
David CARLIER
18df1e4783 ext/gd create gd object with zend_object_alloc (#17823)
while at it, fix build warning "wrong" calloc arguments order
2025-02-16 00:05:37 +00:00
Niels Dossche
82bdc8a2ad Merge branch 'PHP-8.4'
* PHP-8.4:
  [ci skip] Fix GH-17808 dependencies
2025-02-16 00:17:12 +01:00
Niels Dossche
d6c3079910 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [ci skip] Fix GH-17808 dependencies
2025-02-16 00:17:06 +01:00
Niels Dossche
3e879f3dd5 [ci skip] Fix GH-17808 dependencies 2025-02-16 00:16:57 +01:00
Niels Dossche
cbdc1f3f72 Revert "Reduce number of string duplications in phar (#17814)"
This reverts commit 619d29386a.

Just Windows things...
2025-02-16 00:16:08 +01:00
Niels Dossche
5c1dad8e36 Revert "Fix Windows build for GH-17814 and add extension dependency (#17819)"
This reverts commit 5cce35c647.
2025-02-16 00:16:04 +01:00
David CARLIER
dbea8d3385 ext/spl: use zend_object_alloc to create SplObjectStorage instances. (#17824) 2025-02-15 22:33:44 +00:00
David CARLIER
05a155782b ext/gmp: use zend_object_alloc instead to initialize GMP instances. (#17822) 2025-02-15 19:09:36 +00:00
Christoph M. Becker
ed9c283589 Fail build_task.bat if main nmake failed (GH-17820)
Otherwise we may not notice Windows CI build failures.

Fixes GH-17818.
2025-02-15 18:26:11 +01:00
Niels Dossche
5cce35c647 Fix Windows build for GH-17814 and add extension dependency (#17819) 2025-02-15 17:04:55 +01:00
DanielEScherzer
a50f82bebf Zend/tests: organize some tests with sub directories (6) (#17807)
Move more tests into existing directories

Work towards GH-15631
2025-02-15 14:55:07 +00:00
Niels Dossche
619d29386a Reduce number of string duplications in phar (#17814)
We don't need to duplicate these strings from the resource, we can just
use them with an offset.
To prove this was safe, I had to make the arguments const and then
propagate that everywhere, so this patch also introduces some more
constness.
2025-02-15 15:20:29 +01:00
Niels Dossche
c7d62cfd76 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17808: PharFileInfo refcount bug
2025-02-15 13:16:40 +01:00
Niels Dossche
5d8ea65f43 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17808: PharFileInfo refcount bug
2025-02-15 13:16:33 +01:00
Niels Dossche
e735d2bc3b Fix GH-17808: PharFileInfo refcount bug
PharFileInfo just takes a pointer from the manifest without refcounting
anything. If the entry is then removed from the manifest while the
PharFileInfo object still exists, we get a UAF.
We fix this by using the fp_refcount field. This is technically a
behaviour change as the unlinking is now blocked, and potentially file
modifications can be blocked as well. The alternative would be to have a
field that indicates whether deletion is blocked, but similar corruption
bugs may occur as well with file overwrites, so we increment fp_refcount
instead.
This also fixes an issue where a destructor called multiple times
resulted in a UAF as well, by moving the NULL'ing of the entry field out
of the if.

Closes GH-17811.
2025-02-15 13:15:51 +01:00
Niels Dossche
a570ce8f40 Remove custom patches that are no longer in upstream
These were introduced in 6747068c, but they don't seem to be in upstream
(anymore). For the entry in rpm it may have even been a mixup with the
two sections in the rpm file: there's a "10 string" entry but only in
the delta part.
2025-02-15 12:53:07 +01:00
Niels Dossche
37dbad8fcd Upgrade to file 5.46 2025-02-15 12:53:07 +01:00
David CARLIER
d3da2a2884 zend_test: zend_test_compile_string converting script argument to path. (#17810) 2025-02-15 11:15:08 +00:00
David Carlier
01a87e0d2d Merge branch 'PHP-8.4' 2025-02-15 10:12:34 +00:00
David Carlier
eabbb1c1c6 Merge branch 'PHP-8.3' into PHP-8.4 2025-02-15 10:12:20 +00:00
David Carlier
0f63bee3e9 Fix GH-17797: zend_test_compile_string crash on invalid script path.
When looking for the last slash of the script path, it leads to
underflow being promoted to SIZE_MAX being way beyond MAXPATHLEN.

close GH-17801
2025-02-15 10:11:27 +00:00
Shivam Mathur
246c57352e Merge branch 'PHP-8.3' into PHP-8.4 2025-02-14 23:36:04 +00:00
Shivam Mathur
e1f72093ad Merge branch 'PHP-8.2' into PHP-8.3 2025-02-14 23:34:18 +00:00
Shivam Mathur
3becfb1ae6 Merge branch 'PHP-8.1' into PHP-8.2 2025-02-14 23:33:18 +00:00
Shivam Mathur
f4aadb5537 ci: add workflow to trigger windows builds 2025-02-14 23:32:30 +00:00
Niels Dossche
c696087e32 Fix error message on Windows 2025-02-15 00:23:38 +01:00
Niels Dossche
b3dd5a4c86 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix zlib support for large files
  Fix memory leak on overflow in _php_stream_scandir()
2025-02-14 23:11:17 +01:00
Niels Dossche
8f8d4be5eb Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix zlib support for large files
  Fix memory leak on overflow in _php_stream_scandir()
2025-02-14 23:10:40 +01:00
Niels Dossche
5aaf7b4937 Fix zlib support for large files
gzread() and gzwrite() have effectively a 4GiB limit at the moment
because the APIs of the zlib library use unsigned ints.
For example, this means that the count argument of gzread() and gzwrite()
& co effectively are modulo 2**32.
Fix this by adding a loop to handle all bytes.

As for automated testing, I didn't find an easy way to write a phpt for
this that wouldn't use a lot of memory or requires a large file.
For instance, the gzread() test that I manually ran requires a 4MiB
input file (and I can't shrink it because zlib has a max window size).

Here are the testing instructions, run on 64-bit:
To test for gzwrite():
```php
$f = gzopen("out.txt.gz", "w");
gzwrite($f, str_repeat('a', 4*1024*1024*1024+64)); // 4GiB + 64 bytes
```
Then use `zcat out.txt.gz|wc -c` to check that all bytes were written
(should be 4294967360).

To test for gzread():
Create a file containing all a's for example that is 4GiB + 64 bytes.
Then compress it into out.txt.gz using the gzip command.
Then run:
```php
$f = gzopen("out.txt.gz", "r");
$str = gzread($f, 4*1024*1024*1024+64);
var_dump(strlen($str)); // 4294967360
var_dump(substr($str, -3)); // string (3) "aaa"
```

Closes GH-17775.
2025-02-14 23:09:57 +01:00
Niels Dossche
678ecff980 Fix memory leak on overflow in _php_stream_scandir()
On overflow, only the array is freed, but not the strings.

Closes GH-17789.
2025-02-14 23:08:43 +01:00
Christoph M. Becker
252b52ac5a Improve COM ctor exception code for failing ProgIDs (GH-17673)
The `$module_name` of `com::__construct()` can be a ProgID, ClassID or
moniker.  We first try `CLSIDFromString()`, and if that fails, we go
ahead and try to treat the `$module_name` as a moniker.  If that also
fails, we throw an exception with the result of `MkParseDisplayName()`
what would just be `MK_E_SYNTAX` if given a ProgID.  This result is
highly confusing for the common case where a ProgID is given, which is
not registered (e.g. due to a typo).  In this case, we use the original
`HRESULT` (`CO_E_CLASSSTRING`) instead.
2025-02-14 17:44:43 +01:00
Christoph M. Becker
fe9c9049ef Elevate Windows CI to /W3 (sans C4018/C4267) (GH-17665)
C4018[1] is about unsigned/signed comparisons; C4267[2] is about
conversion from `size_t` to a "smaller" type.  We likely should resolve
these warnings in the long run, but for now, it seems like a no brainer
to elevate to `/W3` even if we have to exempt two additional categories
of warnings, since we can catch some others.  And we no longer need to
elevate C4010[3] to a higher level to catch it.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4018>
[2] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267>
[3] <https://learn.microsoft.com/de-de/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4013>
2025-02-14 17:39:54 +01:00
Christoph M. Becker
7c8bd08f6d Implement zend_safe_address() for MSVC 64bit (GH-17679)
The 32bit implementation seems to be okay, but we rather should avoid
falling back to the double (pun intended) calculation for non `__GNUC__`
systems.  We use the intsafe.h intrinsics instead for MSVC and
compatible compilers.
2025-02-14 17:37:27 +01:00
Christoph M. Becker
e9ffe02fa1 Merge branch 'PHP-8.4'
* PHP-8.4:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:19:50 +01:00
Christoph M. Becker
974ed3130e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:19:18 +01:00
Christoph M. Becker
302165837f Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:17:51 +01:00
Christoph M. Becker
595e616292 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Fix phpize for Windows 11 (24H2)
2025-02-14 17:16:04 +01:00
Bob Weinand
7f6c05116e [skip ci] Fix phpize for Windows 11 (24H2)
It seems like n === undefined must have worked on older versions of
jscript, but currently it just causes the insertion to silently fail.
This sets n to an empty string, allowing phpize to include the local
config.w32 files.
2025-02-14 17:15:24 +01:00
nzsys
2d693c4d4a [skip ci] Fix: Remove unused code and clean up regex patterns (GH-17791)
- Removed unused variable  from getHeaders function.
- Simplified regex by removing unnecessary lazy quantifiers ().
- Removed unnecessary  flag from regex patterns.
This improves readability and reduces redundant code without altering functionality.
2025-02-14 16:54:12 +01:00
DanielEScherzer
07e5f6fc3d ReflectionClass::isCloneable(): reduce duplication (GH-17795)
When the `zend_class_entry` has a `zend_function` entry for `clone`, the logic
is the same regardless of if the `reflection_object` entry has an object or
not; the determination is based solely on the flags of the `zend_function`.
2025-02-14 16:50:33 +01:00
David Carlier
77d748617a Merge branch 'PHP-8.4' 2025-02-14 15:29:32 +00:00
David Carlier
ed18fd073a Merge branch 'PHP-8.3' into PHP-8.4 2025-02-14 15:28:48 +00:00
David Carlier
4d7d01d18e Fix GH-17772: imagepalettetotruecolor segfault on invalid truecolor pixel.
close GH-17777
2025-02-14 15:28:33 +00:00
Ilija Tovilo
f25eb7f18d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix curl protocols test expectation
2025-02-14 14:38:58 +01:00
Ilija Tovilo
5b87faaaa7 Fix curl protocols test expectation
Closes GH-17803
2025-02-14 14:38:34 +01:00
David CARLIER
b296712403 zend: gcc 15 will support counted_by(x) instead. (#17790)
gcc gave up on the initial patchset for `element_count` and went
by `counted_by` since last october.
2025-02-14 12:22:10 +00:00
DanielEScherzer
1a468b6efc Docs: add a page about zend_constant (GH-17072) 2025-02-14 12:49:57 +01:00
DanielEScherzer
d22abca488 Zend/tests: organize some tests with sub directories (5) (#17800)
Second pass through `Zend/tests/bug*` to organize the tests.

Move tests to existing sub directories, and create some new sub directories:
* `ArrayAccess`
* `autoload`
* `clone`
* `serialize` (also covers `unserialize()`)
* `switch`

Work towards GH-15631
2025-02-14 11:49:14 +00:00
DanielEScherzer
767ddfc86a bug81626.phpt: replace Cyrillic Small Letter Es [skip ci] (#17799) 2025-02-14 11:47:59 +00:00
David Hein
77d5eb6a5a [skip ci] Fix tests with multiline titles (GH-17763)
See GH-17761
2025-02-14 12:03:53 +01:00