Commit Graph

64088 Commits

Author SHA1 Message Date
Christoph M. Becker
b1211c1e4a
Fix GH-15432: Heap corruption when querying a vector
Since the mysqlnd result set is arena allocated, we must not simply
free it, but rather call the appropriate `free_result` method.

Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
2024-08-20 15:43:21 +02:00
David Carlier
5c9c275743
Checks getrandom availability on solaris.
To fix part of GH-15381.
gcc nor clang provides a constant to distinguish illumos and solaris
not the system provides a kernel version stamp like the BSD.
thus, we simply check the symbol and remaing purposely conservative in
the existing logic, using it only for solaris to avoid unexpected
breakages for other systems. would need a different fix for higher
branches.

Close GH-15390
2024-08-13 20:50:15 +01:00
Christoph M. Becker
1b52ecd78a
Fix test expectation 2024-08-13 19:23:53 +02:00
Niels Dossche
28290655e8
Revert "Fix bug #69280: SoapClient classmap doesn't support fully qualified class name (#14398)"
This reverts commit 476706165a.

Although the fix is correct, people are relying on the bug and their
code stopped working, see GH-15252.
2024-08-07 10:03:12 +02:00
Christoph M. Becker
6713d51631
Fix odbc_data_source_001.phpt
As of PHP 8.1.0, passing `null` to an `int` parameter is deprecated,
and as such the deprecation notice breaks the test.  So we instead pass
an integer, and to avoid hard-coding a value we just add the two
supported constants (which are supposed to have the values `1` and `2`,
respectively).

Closes GH-15254.
2024-08-06 16:54:19 +02:00
Niels Dossche
ca84662c87
Fix crash when converting array data for array in shm in xxh3
Closes GH-15237.
2024-08-05 22:06:11 +02:00
Niels Dossche
11fbe8801b
Fix SoapFault property destruction
Two issues:
1) We should not modify the object when we pass invalid values
2) We should reset the properties to their default value otherwise we
   get a UAF.

Regressed in df219ccf9d

Closes GH-15248.
2024-08-05 22:02:51 +02:00
Niels Dossche
67ce8759e8
Fix GH-15179: Segmentation fault (null pointer dereference) in ext/standard/url_scanner_ex.re
Based on analysis by Ilija: https://github.com/php/php-src/issues/15179#issuecomment-2261546902

* Apply suggestions from code review

Closes GH-15206.

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2024-08-03 02:05:06 +02:00
Niels Dossche
b282dd749f
Fix UAF when removing doctype and using foreach iteration
This is an old bug, but this is pretty easy to fix.
It's basically applying the same fix as I did for e878b9f.
Reported by YuanchengJiang.

Closes GH-15143.
2024-07-30 20:01:22 +02:00
Niels Dossche
fdae7c23f0
Fix CI failure on macOS after Curl update 2024-07-28 14:34:26 +02:00
Niels Dossche
4df858602a
Fix nightly failure in test variation due to number of temp variables varying when observers are enabled 2024-07-27 16:37:01 +02:00
Niels Dossche
404bd30810
Fix CI failure after Curl update (#15124) 2024-07-27 16:09:50 +02:00
Christoph M. Becker
af789afbe8
Fix type incompatibility in assignment.
This partially reverts 0956267c08, which
introduced a type incompatibility where an `int` function is assigned
to a `zend_result` function.  That yields a level 1 C4133 warning on
MSVC, and usually (e.g. in CI) level 1 warnings are elevated to errors,
so the build fails.[1]

The PHP-8.3 branch and up are uneffected by this, so the upward merges
should be empty.

[1] <0956267c08 (r144587696)>
2024-07-26 14:57:16 +02:00
Christoph M. Becker
5fbda73099
Fix GH-15087 IntlChar::foldCase()'s $option is not optional
Since that parameter is supposed to be optional (and has been prior to
PHP 8.0.0), we fix the implementation instead of the stub.

Closes GH-15091.
2024-07-24 16:45:20 +02:00
Levi Morrison
0956267c08
Fix warnings in session/spl
This fixes -Winline errors where the functions are not ever inlined.

Also fixes some signature mismatches which were fixed previously but
for whatever reason were not ported to all maintained branches:

/usr/local/src/php/ext/session/session.c:1299:20:
warning:conflicting types for 'php_session_send_cookie' due to enum/integer mismatch;
have 'zend_result(void)' {aka 'ZEND_RESULT_CODE(void)'} [-Wenum-int-mismatch]
 1299 | static zend_result php_session_send_cookie(void) /* {{{ */
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/src/php/ext/session/session.c💯12:
note: previous declaration of 'php_session_send_cookie' with type 'int(void)'
  100 | static int php_session_send_cookie(void);
      |            ^~~~~~~~~~~~~~~~~~~~~~~
2024-07-23 16:25:11 -06:00
Arnaud Le Blanc
acf758d2ea
Fix build on platforms without JIT support (#15069) 2024-07-23 13:42:47 +02:00
David Carlier
350c10d985
fix GH-14785 pedantic error
close GH-15071
2024-07-22 23:26:09 +01:00
David Carlier
ba909d7c43
Fix GH-14780: p(f)sockopen overflow on timeout argument.
close GH-14785
2024-07-22 22:57:59 +01:00
Arnaud Le Blanc
929536b697
Hint the opcache shm mapping location only when JIT is enabled
Closes GH-14793
Fixes GH-13775
2024-07-22 19:26:54 +02:00
LoongT4o
a924e1c71b
Fix the JIT buffer relocation failure at the corner case (#11266)
Avoid missing possible candidates due to the large address range of the free segment.
Eg, 

48000000-49400000 r-xs 08000000 00:0f 39322841               segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0              segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515       /usr/local/sbin/php-fpm

original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].

Fix issue #11265.

Signed-off-by: Long, Tao <tao.long@intel.com>
Signed-off-by: Dmitry Stogov <dmitrystogov@gmail.com>
2024-07-22 19:17:43 +02:00
Niels Dossche
b8e9c5ba6a
Fix bogus fallthrough path in firebird_handle_get_attribute()
If getting the version fails, we should return -1 according to
php_pdo_driver.h:259, not fall through to another attribute.

Closes GH-15066.
2024-07-22 18:33:03 +02:00
Bob Weinand
a18df90a8b Fix GH-13817: Segmentation fault for enabled observers after pass 4
Instead of fixing up temporaries count in between observer steps, just apply the additional temporary in the two affected observer steps.

Closes GH-14018.
2024-07-22 18:28:03 +02:00
Niels Dossche
fdcfd62b9b
Fix passing non-finite timeout values in stream functions
Closes GH-15061.
2024-07-22 17:52:21 +02:00
Niels Dossche
c0de7214aa
Fix GH-14286 (ffi enum type (when enum has no name) make memory leak)
For top-level anonymous type definition we never store the declaration anywhere
else nor the type anywhere else.
The declaration keeps owning the type and it goes out of scope.
For anonymous fields this gets handled by the add_anonymous_field code that
removes the type from the declaration.
This patch does something similar in the parsing code when it is
detected we're dealing with an anonymous enum in a top-level declaration.

Closes GH-14839.
2024-07-22 17:44:47 +02:00
Dmitry Stogov
d6efff7254
Fix Windows build 2024-07-22 16:41:16 +03:00
Dmitry Stogov
13e9b40517
Regenerate FFI parser using HEAD version of LLK 2024-07-22 16:01:26 +03:00
Peter Kokot
d20d11375f
Append -Wno-implicit-fallthrough flag conditionally (#13331)
Older GCC versions (< 7.0) don't support the -Wno-implicit-fallthrough
compiler flag. This adds the flag conditionally in case some other
compiler will run into same issue.

Fixes GH-13330
2024-07-22 06:57:04 +02:00
Niels Dossche
cfcc2a3fda
Fix GH-15034: Integer overflow on stream_notification_callback byte_max parameter with files bigger than 2GB
We were using atoi, which is only for integers. When the size does not
fit in an integer this breaks. Use ZEND_STRTOUL instead. Also make sure
invalid data isn't accidentally parsed into a file size.

Closes GH-15035.
2024-07-21 22:02:11 +02:00
Niels Dossche
8de7ccb29b
Fix memory leaks in ext/tidy basedir restriction code
TIDY_APPLY_CONFIG can early return because it's a macro, but then the
cleanup paths are not executed. Transform this to a real function and
handle the cleanups correctly at the callsites.

Closes GH-15046.
2024-07-21 16:28:15 +02:00
Niels Dossche
5996227f88
Fix GH-15028: Memory leak in ext/phar/stream.c
Closes GH-15029.
2024-07-19 14:58:28 +02:00
Christoph M. Becker
355baf982e
Revert "Skip bug45161.phpt on Windows"
This reverts commit 4b22c3e3ad.

As quick measure for GH-10753, that test was skipped on Windows.
However, it seems that there are no longer performance issues with
newer cURL versions, so we run that test again on Windows.

Fixes GH-10753.
Closes GH-14998.
2024-07-18 12:42:01 +02:00
David Carlier
efd00b8ff0
ext/curl: curl_error using curl_easy_strerror if CURLOPT_ERRORBUFFER
did not fill the error buffer.

close GH-14984
2024-07-18 06:25:37 +01:00
Niels Dossche
911dc5b46c
Fix bug #55639: Digest autentication dont work
RFC 2617 and 7616 describe that for the "Authorization" header we should
not put the qop nor nc value inside quotes. This differs from the
WWW-Authenticate header, which may have been the source of the confusion
in the implementation. While the version with quotes seems to work fine
in some cases, clearly not all servers accept the non-standard form.
To fix the issue, simply removing the quotes of those two header fields
of the client request to be in line with the RFC suffices.

I refer further to example 3.5 in RFC 2617 and example 3.9.1 in
RFC 7616.

RFC 2617: https://datatracker.ietf.org/doc/html/rfc2617
RFC 7616: https://datatracker.ietf.org/doc/html/rfc7616

Closes GH-14328.
2024-07-17 19:23:10 +02:00
Christoph M. Becker
6d0db52896
Add test case for GH-13774
Besides demonstrating the new behavior, this test also ensures that the
bundled and external libgd now behave the same.  It has to be noted,
though, that we only test one of the five code paths.

Closes GH-14945.
2024-07-14 12:46:37 +02:00
Denis Ryabov
b456ae8d34
Restore Warning instead of Fatal Error in gd_webp.c
According to the docs (https://www.php.net/manual/en/function.imagecreatefromwebp.php and https://www.php.net/manual/en/function.imagewebp.php), `false` should be returned on errors (similar to other functions of the `gd` extension), but actually all errors result in a `Fatal Error`. It doesn't look normal when trying to read an empty file or a file in the wrong format causes the program to stop. The problem seems to be related to a mega-patch that replaced `zend_error` with `zend_error_noreturn` almost everywhere. My patch fixes this behavior by switching from `zend_error_noerror` to `gd_error` (i.e. to `E_WARNING` level). All necessary memory cleanup is already in the code (as it was before the "zend_error_noreturn" patch).

Close GH-13774
2024-07-13 16:58:54 +01:00
Michael Orlitzky
09957ab9a8
ext/gd/tests/gh10614.phpt: skip if no PNG support
This test uses imagecreatefrompng(), which won't be there if libgd was
built without PNG support.

Closes GH-14905.
2024-07-10 19:50:48 +02:00
Niels Dossche
eb8c3cb79a
Fix GH-14741: Segmentation fault in Zend/zend_types.h
The create_obj handler of InternalIterator is overwritten, but not the
clone_obj handler. This is not allowed.
In PHP 8.2 this didn't cause a segfault because the standard object
handler was used for the clone instead of the internal handler.
So then it allocates and frees the object using the standard object handlers.
In 8.3 however, the object is created using the standard object handler and
freed using the custom handler, resulting in the buffer overflow.
Even though bisect points to 1e1ea4f this only reveals the bug.

Closes GH-14882.
2024-07-09 00:56:53 +02:00
Niels Dossche
c34def581a
Fix memory leak in tidy_repair_file()
When dealing with a file, we must free the contents if the function
fails. While here, also fix the error message because previously it
sounded like the filename was too long while in fact the file itself
is too large.

Closes GH-14862.
2024-07-08 13:24:32 +02:00
Niels Dossche
b44ad27a78
Fix GH-14550: No warning message when Zend DTrace is enabled that opcache.jit is implictly disabled
Closes GH-14847.
2024-07-07 13:18:01 +02:00
Niels Dossche
0d4e0c013e
Fix GH-14639: Member access within null pointer in ext/spl/spl_observer.c
`spl_object_storage_attach_handle` creates an entry already, but only
fills it in at the end with `spl_object_storage_create_element` which
allocates memory. In this case the allocation fails and we're left with
a NULL slot. Doing the allocation first isn't an option because we want
to check whether the slot is occupied before allocating memory.
The simplest solution is to set the entry to NULL and check for a NULL
pointer upon destruction.

Closes GH-14849.
2024-07-06 23:57:46 +02:00
David Carlier
237518763f
Fix GH-14774 time_sleep_until overflow. 2024-07-06 20:43:59 +01:00
Niels Dossche
0b6289dab8
[ci skip] Test is for libxml only 2024-07-06 14:41:44 +02:00
Niels Dossche
67259e451d
Fix GH-14834: Error installing PHP when --with-pear is used
libxml2 2.13 makes changes to how the parsing state is set, update our
code accordingly. In particular, it started reporting entities within
attributes, while it should only report entities inside text nodes.

Closes GH-14837.
2024-07-06 13:52:02 +02:00
Niels Dossche
e5e15fd229
Stop setting parse options directly
Setting this directly will be deprecated in libxml2 2.14.
2024-07-06 13:46:16 +02:00
Niels Dossche
823d0588f7
Stop relying on lastError directly
Reading this directly will become deprecated in libxml2 2.14.
2024-07-06 13:46:15 +02:00
Niels Dossche
6490a18271
Stop relying on the sax2 flag directly
Setting this directly will become deprecated in libxml2 2.14.
2024-07-06 13:46:15 +02:00
Niels Dossche
8dc799aac7
Port XML_GetCurrentByteIndex to public APIs
This is necessary to avoid a deprecation break in libxml2 2.14.x.
2024-07-06 13:46:15 +02:00
Niels Dossche
1e5f46fb20
Fix test conflict between gzfile_basic.phpt and gzfile_basic2.phpt
[ci skip]

This should fix the nightly failure.
2024-07-06 01:59:32 +02:00
Niels Dossche
39ed9993f7
Fix GH-13688: Test curl_basic_008 can fail (#13693)
.invalid is a reserved TLD that should never be caught.
2024-07-04 18:07:54 +02:00
Michael Orlitzky
27dd393be9
ext/standard/tests: strings/wordwrap_memory_limit_32bit.phpt has two outputs
It turns out that on a 32-bit system, this test can produce either the
"usual" expected output from the 64-bit test, OR the 32-bit-only
integer overflow message. We copy the dual expected outputs from
chunk_split_variation1_32bit.phpt to handle both cases.

This fixes an earlier commit that split the two tests based only on
the size of an int (32-bit versus 64-bit). The CI reveals that, at
least on a debug/zts build, the "64-bit" memory limit error (and not
the integer overflow error) is still produced.
2024-07-04 15:55:05 +02:00