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

66818 Commits

Author SHA1 Message Date
David CARLIER
18cfd94de4 ext/sockets: multicast simplification on ipv4 table retrieval and buffer handling. (#14542) 2024-06-12 18:33:16 +01:00
Arnaud Le Blanc
d1048a0869 Add zend_random_bytes(), zend_random_bytes_insecure() functions (#14054)
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2024-06-12 17:27:01 +02:00
Peter Kokot
d545b1d643 Add missing ext/pcre dependency for ext/pgsql (#14541) 2024-06-11 23:38:23 +02:00
Peter Kokot
5d3fab9334 Sync #if/ifdef/defined (#14520)
These are either undefined or defined (to value 1):
- __DragonFly__
- __FreeBSD__
- HAS_MCAST_EXT
- HAVE_GETCWD
- HAVE_GETWD
- HAVE_GLIBC_ICONV
- HAVE_JIT
- HAVE_LCHOWN
- HAVE_NL_LANGINFO
- HAVE_RL_CALLBACK_READ_CHAR
- HAVE_RL_ON_NEW_LINE
- HAVE_SQL_EXTENDED_FETCH
- HAVE_UTIME

Follow up of GH-5526 (-Wundef)
2024-06-11 22:47:05 +02:00
Jorg Adam Sowa
45714e2cb8 random: Remove redundant assignments in php_random_rangeX() (#14536)
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2024-06-11 21:36:02 +02:00
Peter Kokot
61a0e3bd19 Sync HAVE_OPENSSL* symbols (#14333)
This syncs few inconsistencies between the Windows and Autotools build
systems:
- HAVE_OPENSSL_EXT is now defined in the same style on both systems
  (undefined - extension is not available, defined to 1 - extension is
  available)
- HAVE_OPENSSL removed as it was only defined on Windows
2024-06-11 19:18:19 +02:00
Saki Takamachi
bfc988552f Fixed GH-14383: Fixed usec was carry up (#14463)
If round to the fractional part of a timestamp, a carry will occur in cases
such as 999 999 9. In that case, set usec to 0 and add/sub 1 to sec.
2024-06-11 19:02:43 +09:00
Peter Kokot
5433f02e79 Use default argument in AS_CASE instead of pattern 2024-06-11 11:26:52 +02:00
David CARLIER
1ae544330c ext/gd using fast ZPP. (#14534) 2024-06-11 09:01:54 +01:00
Peter Kokot
bd7b174044 Update ext/spl as required dependency for ext/pdo (#14535)
Since ZEND_MOD_REQUIRED is used and spl can't be disabled, this marks
the configure time dependency also as required.
2024-06-11 09:59:58 +02:00
Peter Kokot
845af7778e Remove redundant win32/unistd.h includes (#14533)
At this point win32/unistd.h only declares usleep which isn't used at
these places.
2024-06-11 09:47:23 +02:00
Ilija Tovilo
998bce117c Show enum cases in errors
Closes GH-14496
2024-06-10 22:58:25 +02:00
Peter Kokot
a82d86479c Replace WIN32 conditions with _WIN32 or PHP_WIN32 (#14462)
* Replace WIN32 conditions with _WIN32 or PHP_WIN32

WIN32 is defined by the SDK and not defined all the time on Windows by
compilers or the environment. _WIN32 is defined as 1 when the
compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise,
undefined.

This syncs these usages one step further.

Upstream libgd has replaced WIN32 with _WIN32 via
c60d9fe577

PHP_WIN32 is added to ext/sockets/sockets.stub.php as done in other
*.stub.php files at this point.

* Use PHP_WIN32 in ext/random

* Use PHP_WIN32 in ext/sockets

* Use _WIN32 in xxhash.h as done upstream

See https://github.com/Cyan4973/xxHash/pull/931

* Update end comment with PHP_WIN32
2024-06-10 21:59:41 +02:00
Niels Dossche
bcecbb59d3 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-11078: PHP Fatal error triggers pointer being freed was not allocated and malloc: double free for ptr errors
2024-06-10 19:40:03 +02:00
Niels Dossche
ccdd1c4e67 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-11078: PHP Fatal error triggers pointer being freed was not allocated and malloc: double free for ptr errors
2024-06-10 19:39:25 +02:00
Niels Dossche
bc558bf7a3 Fix GH-11078: PHP Fatal error triggers pointer being freed was not allocated and malloc: double free for ptr errors
Although the issue was demonstrated using Curl, the issue is purely in
the streams layer of PHP.

Full analysis is written in GH-11078 [1], but here is the brief version:
Here's what actually happens:
1) We're creating a FILE handle from a stream using the casting mechanism.
   This will create a cookie-based FILE handle using funopen.
2) We're reading stream data using fread from the userspace stream. This will
   temporarily set a buffer into a field _bf.base [2]. This buffer is now equal
   to the upload buffer that Curl allocated and note that that buffer is owned
   by Curl.
3) The fatal error occurs and we bail out from the fread function, notice how
   the reset code is never executed and so the buffer will still point to
   Curl's upload buffer instead of FILE's own buffer [3].
4) The resources are destroyed, this includes our opened stream and because the
   FILE handle is cached, it gets destroyed as well.
   In fact, the stream code calls through fclose on purpose in this case.
5) The fclose code frees the _bs.base buffer [4].
   However, this is not the buffer that FILE owns but the one that Curl owns
   because it isn't reset properly due to the bailout!
6) The objects are getting destroyed, and so the curl free logic is invoked.
   When Curl tries to gracefully clean up, it tries to free the buffer.
   But that buffer is actually already freed mistakingly by the C library!

This also explains why we can't reproduce it on Linux: this bizarre buffer
swapping only happens on macOS and BSD, not on Linux.

To solve this, we switch to an unbuffered mode for cookie-based FILEs.
This avoids any stateful problems related to buffers especially when the
bailout mechanism triggers. As streams have their own buffering
mechanism, I don't expect this to impact performance.

[1] https://github.com/php/php-src/issues/11078#issuecomment-2155616843
[2] 5e566be7a7/stdio/FreeBSD/fread.c (L102-L103)
[3] 5e566be7a7/stdio/FreeBSD/fread.c (L117)
[4] 5e566be7a7/stdio/FreeBSD/fclose.c (L66-L67)

Closes GH-14524.
2024-06-10 19:38:21 +02:00
Arnaud Le Blanc
b4325d6113 Improve randomness of uploaded file names and files created by tempnam()
Closes GH-14364
2024-06-10 15:37:51 +02:00
Gina Peter Banyard
7130a174bb ext/opcache/jit: Fix -Wundef warning for HAVE_CAPSTONE
All other times this symbol is references #ifdef is used
2024-06-10 14:19:59 +01:00
Tim Düsterhus
193d3850b2 Leverage object_init_with_constructor() in zend_get_attribute_object() (#14532) 2024-06-10 15:12:22 +02:00
Dmitry Stogov
6c9d443a21 Update IR
IR commit: 5be6dd81f19f85bc06085617e7231f8699d7f9b0
2024-06-10 11:49:08 +03:00
Peter Kokot
c3388c1841 Sync #if/ifdef/defined (#14512)
These are either undefined or defined to 1:
- HAVE_LIBEDIT
- HAVE_LIBREADLINE
- ZEND_MAX_EXECUTION_TIMERS

Follow up of GH-5526 (-Wundef)
2024-06-10 08:56:10 +02:00
Peter Kokot
d3901b8ca6 Sync PHP_FILEINFO_UNCOMPRESS #if/ifdef/defined (#14525)
This fixes few more -Wundef warnings in ext/fileinfo. The
PHP_FILEINFO_UNCOMPRESS seems to be present to be defined at some point
but is currently unused in all build systems. Leaving this intact for
now.

Follow up of GH-5526 (-Wundef)
2024-06-10 08:11:25 +02:00
Peter Kokot
84a0da1574 Sync #if/ifdef/defined (#14508)
This syncs CPP macro conditions:
- _WIN32
- _WIN64
- HAVE_ALLOCA_H
- HAVE_ALPHASORT
- HAVE_ARPA_INET_H
- HAVE_CONFIG_H
- HAVE_DIRENT_H
- HAVE_DLFCN_H
- HAVE_GETTIMEOFDAY
- HAVE_LIBDL
- HAVE_POLL_H
- HAVE_PWD_H
- HAVE_SCANDIR
- HAVE_SYS_FILE_H
- HAVE_SYS_PARAM_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_TIME_H
- HAVE_SYS_TYPES_H
- HAVE_SYS_WAIT_H
- HAVE_UNISTD_H
- PHP_WIN32
- ZEND_WIN32

These are either undefined or defined to 1 in Autotools and Windows.

Follow up of GH-5526 (-Wundef).
2024-06-09 14:23:41 +02:00
Jakub Zelenka
82e6040cff Merge branch 'PHP-8.2' into PHP-8.3 2024-06-09 12:40:51 +01:00
Jakub Zelenka
46013f1c55 Skip test for OpenSSL bug #74341 which is not a bug 2024-06-09 12:40:24 +01:00
Jakub Zelenka
98736e8bbd Fix GH-13343: openssl_x509_parse should not allow omitted seconds in UTCTimes
Closes GH-14439

Signed-off-by: Jakub Zelenka <bukka@php.net>
2024-06-09 12:35:05 +01:00
Peter Kokot
65ff5117ab Check for PQERRORS_SQLSTATE in PGVerbosity enum (#14519)
The PG_VERSION_NUM is not available in intended public PostgreSQL
headers unless the pg_config.h is included or the PostgreSQL server
development headers are installed separately. This instead resorts to
checking for the PGVerbosity enum value. The PQERRORS_SQLSTATE was added
to PostgreSQL 12.0. At the time of writing, on Windows, PostgreSQL is at 11.4 so
it is not defined there yet.
2024-06-09 11:47:06 +02:00
Peter Kokot
aae237aad5 Add missing sodium.h header (#14515)
The php_libsodium.h uses SODIUM_LIBRARY_VERSION_* macros from the
sodium.h (sodium/version.h) header.
2024-06-09 07:17:46 +02:00
Peter Kokot
0dcb467dae Sync #if/ifdef/defined (#14511)
These are either undefined or defined to value 1:
- ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE
- ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
- ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO
- ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR

Follow up of GH-5526 (-Wundef)
2024-06-09 07:13:23 +02:00
Peter Kokot
01887afdfa Fix typo s/PGVERSION_NUM/PG_VERSION_NUM (#14516) 2024-06-09 06:48:44 +02:00
Guillaume Outters
a9259c0496 Add Pdo\Pgsql::setNoticeCallback() (#14299)
This moves the new method from magically being added to the PDO class from the driver to just be available on the dedicated subclass. 

Drive-by fixes to NEWS and UPGRADING
2024-06-09 03:04:51 +01:00
Saki Takamachi
25579a8616 ext/bcmath: Renamed macros and variables (#14507)
Made the macro BC_UINT_T a typedef and renamed it BC_VECTOR.

Additionally, several macros have been renamed to be consistent with BC_VECTOR.
2024-06-09 09:11:11 +09:00
Peter Kokot
f109795852 Sync HAVE_GRP_H definition (#14514)
This syncs the HAVE_GRP_H definition on Windows (manually defined) and
Autotools (checked with AC_CHECK_HEADERS):
HAVE_GRP_H is is either undefined or defined to value 1.
2024-06-09 01:55:27 +02:00
Gina Peter Banyard
a5cacba6d8 ext/spl: Remove spl_engine.h header (#14418)
And convert calls to spl_instantiate_arg_* to the new object_init_with_constructor() API
2024-06-08 23:46:34 +01:00
Ayesh Karunaratne
d8795a3503 ext/pcre: update Config to match upstream (#14509)
In GH-14498, we updated pcre2lib to v10.44. However, it missed syncing the config,
that changes upstream `MAX_NAME_SIZE` from 32 to 128.

Ref: [1](ced3b0f06f (diff-91c5b46dc84a94604a4e4d0caed9bf85590a2eddbb12d2e8dc80badf324a9dfb)), [2](6c670c780a)
2024-06-08 21:34:18 +02:00
Peter Kokot
743d1fd2a2 Sync -Wno-implicit-fallthrough
This is a sync of the https://github.com/php/php-src/pull/6252 after few
years:
- ext/date: pending recheck in GH-14187
- ext/hash: warning happens only on 32-bit build in
  ext/hash/sha3/generic32lc/KeccakP-1600-inplace32BI.c
- ext/opcache: IR JIT doesn't seem to have this issue
- ext/pcre remains disabled due to pcre2lib/sljit/sljitNativeARM_64.c
  (should be rechecked and fixed upstream)
2024-06-08 20:04:21 +02:00
Gina Peter Banyard
fd2d869642 Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Gina Peter Banyard
8f6612aca0 ext/date: Fix some [-Wsign-compare] warnings 2024-06-08 17:15:01 +01:00
Gina Peter Banyard
194a2c1b54 ext/standard/url.c fix a [-Wsign-compare] warning 2024-06-08 17:15:01 +01:00
Gina Peter Banyard
8c16076dc3 ext/random: Fix signess issues 2024-06-08 17:15:01 +01:00
Gina Peter Banyard
efee76b8e2 ext/json: Fix sign conversion warnings 2024-06-08 17:15:01 +01:00
Peter Kokot
9dbcb91152 Refactor check for libcurl linkage with OpenSSL < 1.1 (#14319)
- One excessive AC_MSG_RESULT removed
- AC_RUN_IFELSE wrapped in AC_CACHE_CHECK for easier cross-compiling
  edge cases
- Check wrapped in the thread safety condition since this is relevant
  only when ZTS is enabled
2024-06-08 17:59:59 +02:00
Ayesh Karunaratne
d1f14a4609 ext/pcre: update to PCRE2 v10.44 (#14498)
Previously: GH-13413.

This version also contains a fix with `preg_match('\X')`, so that it
can correctly detect grapheme clusters (PCRE2Project/pcre2#410).
This is useful to correctly [polyfill the new `grapheme_str_split`
function](https://php.watch/versions/8.4/grapheme_str_split#polyfill).

Diff: pcre2lib [v10.43..v10.44](https://github.com/PCRE2Project/pcre2/compare/pcre2-10.43...pcre2-10.44)
2024-06-08 13:03:31 +02:00
Peter Kokot
5a03ff4f6c Remove PHP_SETUP_OPENSSL inactive 3rd argument (#14323)
If OpenSSL is not found, the PKG_CHECK_MODULES errors out already. To
not introduce too big of a BC break with possible PECL extensions using
this macro, it is perhaps simpler to remove this non-working argument.
Redundant macro arguments are ignored by Autoconf anyway.
2024-06-07 23:48:17 +02:00
Peter Kokot
da86eec3db Sync #if/ifdef/defined (#14371)
These are either undefined or defined to value 1 in Autotools and
Windows:
- HAVE_COMMONCRYPTO_COMMONRANDOM_H
- HAVE_EXIF
- HAVE_FOPENCOOKIE
- HAVE_IF_NAMETOINDEX
- HAVE_LIBICONV
- HAVE_SOCKETS
- HAVE_STRUCT_STAT_ST_RDEV
- HAVE_STRUCT_TM_TM_GMTOFF
- HAVE_STRUCT_TM_TM_ZONE

Follow up of GH-5526 (-Wundef)
2024-06-07 23:45:17 +02:00
Peter Kokot
58f3b676f5 Replace WINDOWS with PHP_WIN32 in ext/standard/filestat.c (#14464)
The WINDOWS symbol is project defined symbol in most cases and can be
replaced with PHP_WIN32 in this case at this point.
2024-06-07 23:38:55 +02:00
Peter Kokot
271f91169e Remove WINDOWS symbol from ext/ldap/ldap.c (#14468)
The WINDOWS symbol was used up to commit
f79688e848 where it got undefined when
condition `#if WIN32|WINNT` was met. Then the condition was replaced
with simpler PHP_WIN32 (which today implies also 64-bit platforms) and
WINDOWS is undefined in this file when targeting Windows platform.
Conditions otherwise also work on Windows anyway because of the
LDAP_API_VERSION check.
2024-06-07 23:27:22 +02:00
Peter Kokot
9f63836cf4 Remove redundant _WIN32 compile definitions (#14458)
_WIN32 is defined by all compilers on Windows when targeting 32-bit ARM,
64-bit ARM, x86, or x64. This removes redundant definition in ext/zip
and erroneous CFLAG_ENCHANT variable (should be CFLAGS_ENCHANT).
2024-06-07 22:59:30 +02:00
Peter Kokot
cfb739585f Check ext/pcntl required functions with for loop (#14302)
This omits defining redundant HAVE_<function> symbols since these are
used unconditionally in ext/pcntl.

* HAVE_FORK is defined via ext/standard/config.m4
* HAVE_SIGACTION is defined via Zend.m4
* HAVE_WAITPID symbol is removed
2024-06-07 22:49:02 +02:00
Gina Peter Banyard
51379d66ec Zend: Add object_init_with_constructor() API (#14440)
This will instantiate the object and execute its constructor with the given parameters.
2024-06-06 21:21:16 +01:00