Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,15 @@ function select_jobs($repository, $trigger, $nightly, $labels, $php_version, $re
$jobs['SOLARIS'] = true;
}
if ($all_jobs || !$no_jobs || $test_windows) {
$jobs['WINDOWS']['matrix'] = $all_variations
? ['include' => [
['asan' => true, 'opcache' => true, 'x64' => true, 'zts' => true],
['asan' => false, 'opcache' => false, 'x64' => false, 'zts' => false],
]]
: ['include' => [['asan' => false, 'opcache' => true, 'x64' => true, 'zts' => true]]];
$matrix = [['asan' => false, 'opcache' => true, 'x64' => true, 'zts' => true]];
if ($all_variations) {
$matrix[] = ['asan' => true, 'opcache' => true, 'x64' => true, 'zts' => true];
$matrix[] = ['asan' => false, 'opcache' => false, 'x64' => false, 'zts' => false];
if (version_compare($php_version, '8.5', '>=')) {
$matrix[] = ['asan' => false, 'opcache' => true, 'x64' => true, 'zts' => true, 'clang' => true];
}
}
$jobs['WINDOWS']['matrix'] = ['include' => $matrix];
$jobs['WINDOWS']['config'] = version_compare($php_version, '8.4', '>=')
? ['vs_crt_version' => 'vs17']
: ['vs_crt_version' => 'vs16'];
Expand Down
8 changes: 7 additions & 1 deletion .github/scripts/windows/build_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ if %errorlevel% neq 0 exit /b 3
if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts
if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS%
if "%ASAN%" equ "1" set ADD_CONF=%ADD_CONF% --enable-sanitizer --enable-debug-pack
if "%CLANG_TOOLSET%" equ "1" set ADD_CONF=%ADD_CONF% --with-toolset=clang

rem C4018: comparison: signed/unsigned mismatch
rem C4146: unary minus operator applied to unsigned type
rem C4244: type conversion, possible loss of data
rem C4267: 'size_t' type conversion, possible loss of data
set CFLAGS=/W3 /WX /wd4018 /wd4146 /wd4244 /wd4267
if "%CLANG_TOOLSET%" equ "1" (
rem Clang is much stricter than MSVC, produces too many warnings that would fail the build with /WX
set CFLAGS=/W3 /wd4018 /wd4146 /wd4244 /wd4267
) else (
set CFLAGS=/W3 /WX /wd4018 /wd4146 /wd4244 /wd4267
)

cmd /c configure.bat ^
--enable-snapshot-build ^
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ jobs:
strategy:
fail-fast: false
matrix: ${{ fromJson(inputs.branch).jobs.WINDOWS.matrix }}
name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || ''}}"
name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || ''}}${{ matrix.clang && '_CLANG' || ''}}"
runs-on: windows-2022
env:
PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
Expand All @@ -954,6 +954,7 @@ jobs:
PARALLEL: -j2
OPCACHE: "${{ matrix.opcache && '1' || '0' }}"
ASAN: "${{ matrix.asan && '1' || '0' }}"
CLANG_TOOLSET: "${{ matrix.clang && '1' || '0' }}"
steps:
- name: git config
run: git config --global core.autocrlf false && git config --global core.eol lf
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ PHP NEWS

- GMP:
. gmp_fact() reject values larger than unsigned long. (David Carlier)
. gmp_pow/binomial/root/rootrem and shift/pow operators reject values
larger than unsigned long. (David Carlier)

- Hash:
. Upgrade xxHash to 0.8.2. (timwolla)
Expand Down Expand Up @@ -166,6 +168,8 @@ PHP NEWS
throw a ValueError. (alexandre-daubois)
. array_change_key_case() now raises a ValueError when an invalid $case
argument value is passed. (Girgias)
. linkinfo() now raises a ValueError when the argument is an empty string.
(Weilin Du)

- Streams:
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream
Expand Down
7 changes: 6 additions & 1 deletion TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,14 @@ TSRM_API bool tsrm_is_managed_thread(void);
#define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])
#define TSRMG_FAST_STATIC(offset, type, element) (TSRMG_FAST_BULK_STATIC(offset, type)->element)
#define TSRMG_FAST_BULK_STATIC(offset, type) ((type) (((char*) TSRMLS_CACHE)+(offset)))
#ifdef __cplusplus
#define TSRMLS_MAIN_CACHE_EXTERN() extern "C" { extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; }
#define TSRMLS_CACHE_EXTERN() extern "C" { extern TSRM_TLS void *TSRMLS_CACHE; }
#else
#define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR;
#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE;
#endif
#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL;
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
#define TSRMLS_CACHE _tsrm_ls_cache
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ PHP 8.6 UPGRADE NOTES
argument value is passed.
. array_change_key_case() now raises a ValueError when an invalid $case
argument value is passed.
. linkinfo() now raises a ValueError when the $path argument is empty.
. pathinfo() now raises a ValueError when an invalid $flag
argument value is passed.
. scandir() now raises a ValueError when an invalid $sorting_order
Expand Down Expand Up @@ -154,6 +155,13 @@ PHP 8.6 UPGRADE NOTES
- GMP:
. gmp_fact() now throws a ValueError() if $num does not fit into
a unsigned long.
. gmp_pow(), gmp_binomial(), gmp_root() and gmp_rootrem() now throw a
ValueError if their second argument does not fit into an unsigned long.
. The shift (<<, >>) and exponentiation (**) operators on GMP objects
now throw a ValueError if the right operand does not fit into an
unsigned long.
. gmp_powm() modulo-by-zero now raises a DivisionByZeroError whose
message includes the function name and argument index ($modulus).

- mysqli:
. The return structure of mysqli_get_charset() no longer contains
Expand Down
29 changes: 12 additions & 17 deletions ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val
shift = Z_LVAL_P(op2);
}

if (shift < 0) {
if (shift < 0 || shift > ULONG_MAX) {
zend_throw_error(
zend_ce_value_error, "%s must be greater than or equal to 0",
opcode == ZEND_POW ? "Exponent" : "Shift"
zend_ce_value_error, "%s must be between 0 and %lu",
opcode == ZEND_POW ? "Exponent" : "Shift", ULONG_MAX
);
ZVAL_UNDEF(return_value);
return FAILURE;
Expand Down Expand Up @@ -1087,11 +1087,6 @@ ZEND_FUNCTION(gmp_fact)
GMP_Z_PARAM_INTO_MPZ_PTR(gmpnum)
ZEND_PARSE_PARAMETERS_END();

if (mpz_sgn(gmpnum) < 0) {
zend_argument_value_error(1, "must be greater than or equal to 0");
RETURN_THROWS();
}

if (!mpz_fits_ulong_p(gmpnum)) {
zend_argument_value_error(1, "must be between 0 and %lu", ULONG_MAX);
RETURN_THROWS();
Expand All @@ -1114,8 +1109,8 @@ ZEND_FUNCTION(gmp_binomial)
Z_PARAM_LONG(k)
ZEND_PARSE_PARAMETERS_END();

if (k < 0) {
zend_argument_value_error(2, "must be greater than or equal to 0");
if (k < 0 || k > ULONG_MAX) {
zend_argument_value_error(2, "must be between 0 and %lu", ULONG_MAX);
RETURN_THROWS();
}

Expand All @@ -1136,8 +1131,8 @@ ZEND_FUNCTION(gmp_pow)
Z_PARAM_LONG(exp)
ZEND_PARSE_PARAMETERS_END();

if (exp < 0) {
zend_argument_value_error(2, "must be greater than or equal to 0");
if (exp < 0 || exp > ULONG_MAX) {
zend_argument_value_error(2, "must be between 0 and %lu", ULONG_MAX);
RETURN_THROWS();
}

Expand All @@ -1163,7 +1158,7 @@ ZEND_FUNCTION(gmp_powm)
}

if (!mpz_cmp_ui(gmpnum_mod, 0)) {
zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
zend_argument_error(zend_ce_division_by_zero_error, 3, "Modulo by zero");
RETURN_THROWS();
}

Expand Down Expand Up @@ -1226,8 +1221,8 @@ ZEND_FUNCTION(gmp_root)
Z_PARAM_LONG(nth)
ZEND_PARSE_PARAMETERS_END();

if (nth <= 0) {
zend_argument_value_error(2, "must be greater than 0");
if (nth <= 0 || nth > ULONG_MAX) {
zend_argument_value_error(2, "must be between 1 and %lu", ULONG_MAX);
RETURN_THROWS();
}

Expand All @@ -1253,8 +1248,8 @@ ZEND_FUNCTION(gmp_rootrem)
Z_PARAM_LONG(nth)
ZEND_PARSE_PARAMETERS_END();

if (nth <= 0) {
zend_argument_value_error(2, "must be greater than or equal to 1");
if (nth <= 0 || nth > ULONG_MAX) {
zend_argument_value_error(2, "must be between 1 and %lu", ULONG_MAX);
RETURN_THROWS();
}

Expand Down
4 changes: 2 additions & 2 deletions ext/gmp/tests/gmp_binomial.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
--EXPECTF--
object(GMP)#1 (1) {
["num"]=>
string(3) "252"
Expand Down Expand Up @@ -67,4 +67,4 @@ object(GMP)#2 (1) {
["num"]=>
string(1) "7"
}
gmp_binomial(): Argument #2 ($k) must be greater than or equal to 0
gmp_binomial(): Argument #2 ($k) must be between 0 and %d
8 changes: 4 additions & 4 deletions ext/gmp/tests/gmp_fact.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ try {

echo "Done\n";
?>
--EXPECT--
--EXPECTF--
string(1) "1"
gmp_fact(): Argument #1 ($num) is not an integer string
string(1) "1"
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
gmp_fact(): Argument #1 ($num) must be between 0 and %d
gmp_fact(): Argument #1 ($num) must be between 0 and %d
string(19) "2432902008176640000"
string(65) "30414093201713378043612608166064768844377641568960512000000000000"
string(7) "3628800"
string(1) "1"
string(9) "479001600"
gmp_fact(): Argument #1 ($num) must be greater than or equal to 0
gmp_fact(): Argument #1 ($num) must be between 0 and %d
gmp_fact(): Argument #1 ($num) must be of type GMP|string|int, array given
Done
58 changes: 58 additions & 0 deletions ext/gmp/tests/gmp_overflow_llp64.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--TEST--
GMP functions reject values larger than unsigned long on LLP64
--EXTENSIONS--
gmp
--SKIPIF--
<?php
if (PHP_OS_FAMILY !== "Windows" || PHP_INT_SIZE !== 8) die("skip LLP64 (Windows 64-bit) only");
?>
--FILE--
<?php

try {
gmp_pow(2, PHP_INT_MAX);
} catch (ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}

try {
gmp_binomial(10, PHP_INT_MAX);
} catch (ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}

try {
gmp_root(10, PHP_INT_MAX);
} catch (ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}

try {
gmp_rootrem(10, PHP_INT_MAX);
} catch (ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}

$n = gmp_init(2);
try {
$n << PHP_INT_MAX;
} catch (ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}

try {
$n ** PHP_INT_MAX;
} catch (ValueError $e) {
echo $e->getMessage() . PHP_EOL;
}

echo "Done\n";
?>
--EXPECTF--
gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
gmp_binomial(): Argument #2 ($k) must be between 0 and %d
gmp_root(): Argument #2 ($nth) must be between 1 and %d
gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
Shift must be between 0 and %d
Exponent must be between 0 and %d
Done
6 changes: 3 additions & 3 deletions ext/gmp/tests/gmp_pow.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ try {

echo "Done\n";
?>
--EXPECT--
--EXPECTF--
string(4) "1024"
string(4) "1024"
string(5) "-2048"
string(4) "1024"
string(1) "1"
gmp_pow(): Argument #2 ($exponent) must be greater than or equal to 0
gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
string(4) "1024"
string(14) "10240000000000"
string(17) "97656250000000000"
gmp_pow(): Argument #2 ($exponent) must be greater than or equal to 0
gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
string(14) "10240000000000"
string(14) "10240000000000"
gmp_pow(): Argument #2 ($exponent) must be of type int, array given
Expand Down
4 changes: 2 additions & 2 deletions ext/gmp/tests/gmp_pow2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ object(GMP)#%d (1) {
["num"]=>
string(4) "1024"
}
Exponent must be greater than or equal to 0
Exponent must be greater than or equal to 0
Exponent must be between 0 and %d
Exponent must be between 0 and %d
6 changes: 3 additions & 3 deletions ext/gmp/tests/gmp_pown.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var_dump(gmp_powm(10, $n, 10));

echo "Done\n";
?>
--EXPECT--
--EXPECTF--
string(1) "0"
string(1) "5"
string(1) "5"
Expand All @@ -73,8 +73,8 @@ string(3) "533"
string(3) "331"
string(3) "171"
string(3) "371"
Modulo by zero
Modulo by zero
gmp_powm(): Argument #3 ($modulus) Modulo by zero
gmp_powm(): Argument #3 ($modulus) Modulo by zero
gmp_powm(): Argument #1 ($num) must be of type GMP|string|int, array given
gmp_powm(): Argument #2 ($exponent) must be of type GMP|string|int, array given
gmp_powm(): Argument #2 ($exponent) must be of type GMP|string|int, TypeError given
Expand Down
4 changes: 2 additions & 2 deletions ext/gmp/tests/gmp_remroot.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ array(2) {
string(1) "0"
}
}
gmp_rootrem(): Argument #2 ($nth) must be greater than or equal to 1
gmp_rootrem(): Argument #2 ($nth) must be greater than or equal to 1
gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
4 changes: 2 additions & 2 deletions ext/gmp/tests/gmp_root.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ object(GMP)#%d (1) {
["num"]=>
string(1) "0"
}
gmp_root(): Argument #2 ($nth) must be greater than 0
gmp_root(): Argument #2 ($nth) must be greater than 0
gmp_root(): Argument #2 ($nth) must be between 1 and %d
gmp_root(): Argument #2 ($nth) must be between 1 and %d
6 changes: 3 additions & 3 deletions ext/gmp/tests/overloading.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ $a .= '17';
var_dump($a);

?>
--EXPECT--
--EXPECTF--
object(GMP)#3 (1) {
["num"]=>
string(2) "59"
Expand Down Expand Up @@ -254,8 +254,8 @@ object(GMP)#5 (1) {
["num"]=>
string(3) "-11"
}
Shift must be greater than or equal to 0
Shift must be greater than or equal to 0
Shift must be between 0 and %d
Shift must be between 0 and %d
object(GMP)#5 (1) {
["num"]=>
string(3) "-43"
Expand Down
1 change: 1 addition & 0 deletions ext/phar/func_interceptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ void phar_intercept_functions_shutdown(void)
PHAR_RELEASE(fopen);
PHAR_RELEASE(file_get_contents);
PHAR_RELEASE(is_file);
PHAR_RELEASE(is_link);
PHAR_RELEASE(is_dir);
PHAR_RELEASE(opendir);
PHAR_RELEASE(file_exists);
Expand Down
Loading