Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions ext/fileinfo/fileinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ PHP_FUNCTION(finfo_buffer)
RETURN_THROWS();
}

if (ZEND_NUM_ARGS() == 4 || (hasThis() && ZEND_NUM_ARGS() == 3)) {
php_error_docref(NULL, E_DEPRECATED, "The $context parameter has no effect for finfo_buffer()");
if (UNEXPECTED(EG(exception))) {
RETURN_THROWS();
}
}

if (!Z_FINFO_P(self)->magic) {
zend_throw_error(NULL, "Invalid finfo object");
RETURN_THROWS();
Expand Down
20 changes: 20 additions & 0 deletions ext/fileinfo/tests/finfo_buffer_deprecated_context_param.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
finfo_buffer() deprecated $context param
--EXTENSIONS--
fileinfo
--FILE--
<?php

$finfo = finfo_open();
$buffer = "Regular string here";

var_dump(finfo_buffer($finfo, $buffer, FILEINFO_NONE, null));
var_dump($finfo->buffer($buffer, FILEINFO_NONE, null));

?>
--EXPECTF--
Deprecated: finfo_buffer(): The $context parameter has no effect for finfo_buffer() in %s on line %d
string(36) "ASCII text, with no line terminators"

Deprecated: finfo::buffer(): The $context parameter has no effect for finfo_buffer() in %s on line %d
string(36) "ASCII text, with no line terminators"
16 changes: 15 additions & 1 deletion ext/intl/php_intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,24 @@ const char *intl_locale_get_default( void )
return INTL_G(default_locale);
}

static PHP_INI_MH(OnUpdateErrorLevel)
{
zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
*p = zend_ini_parse_quantity_warn(new_value, entry->name);
if (*p) {
php_error_docref("session.configuration", E_DEPRECATED,
"Using a value different than 0 for intl.error_level is deprecated,"
" as the intl.error_level INI setting is deprecated."
" Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors"
" or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors");
}
return SUCCESS;
}

/* {{{ INI Settings */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateErrorLevel, error_level, zend_intl_globals, intl_globals)
STD_PHP_INI_BOOLEAN("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals)
PHP_INI_END()
/* }}} */
Expand Down
3 changes: 2 additions & 1 deletion ext/intl/tests/gh17469.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ try {
}
?>
--EXPECTF--
Deprecated: ini_set(): Using a value different than 0 for intl.error_level is deprecated, as the intl.error_level INI setting is deprecated. Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors in %s on line %d

Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d

Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d
UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR
UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR
2 changes: 2 additions & 0 deletions ext/intl/tests/ini_use_exceptions_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ var_dump($t->transliterate('a', 3));
--EXPECTF--
string(133) "Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)"

Deprecated: ini_set(): Using a value different than 0 for intl.error_level is deprecated, as the intl.error_level INI setting is deprecated. Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors in %s on line %d

Notice: Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d
bool(false)
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ try {
}
?>
--EXPECT--
ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #1 ($type) must be between -2147483648 and 2147483647
ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #3 ($rawOffset) must be between -2147483648 and 2147483647
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ IntlTimeZone::createTimeZoneIDEnumeration(): variant without region
intl
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
$enum = IntlTimeZone::createTimeZoneIDEnumeration(
IntlTimeZone::TYPE_ANY);
$countAny = count(iterator_to_array($enum));
Expand Down
12 changes: 6 additions & 6 deletions ext/intl/timezone/timezone_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone)

tzobj = Z_PHPTIMEZONE_P(zv_timezone);
if (!tzobj->initialized) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"DateTimeZone object is unconstructed");
RETURN_NULL();
zend_throw_error(NULL, "DateTimeZone object is unconstructed");
RETURN_THROWS();
}

tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL);
Expand Down Expand Up @@ -209,7 +208,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration)

if (!arg3isnull) {
if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(offset_arg))) {
zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX);
zend_argument_value_error(3, "must be between %d and %d", INT32_MIN, INT32_MAX);
RETURN_THROWS();
}
offset = static_cast<int32_t>(offset_arg);
Expand Down Expand Up @@ -311,8 +310,9 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id)
Z_PARAM_LONG(index)
ZEND_PARSE_PARAMETERS_END();

if (UNEXPECTED(index < (zend_long)INT32_MIN || index > (zend_long)INT32_MAX)) {
RETURN_FALSE;
if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(index))) {
zend_argument_value_error(2, "must be between %d and %d", INT32_MIN, INT32_MAX);
RETURN_THROWS();
}

UErrorCode status = UErrorCode();
Expand Down
21 changes: 18 additions & 3 deletions ext/openssl/openssl_backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,13 +1344,20 @@ EVP_PKEY *php_openssl_pkey_from_zval(
return key;
}

zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t key_size)
{
EVP_PKEY_CTX *ctx = php_openssl_pkey_new_from_pkey(key);
zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t requested_key_size) {
size_t key_size = requested_key_size;
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(key, NULL);
if (!ctx) {
return NULL;
}

#if OPENSSL_VERSION_NUMBER < 0x30000000L
/* OpenSSL 1.1 does not respect key_size for DH, so force size discovery so it can be compared later. */
if (EVP_PKEY_base_id(key) == EVP_PKEY_DH && key_size != 0) {
key_size = 0;
}
#endif

if (EVP_PKEY_derive_init(ctx) <= 0 ||
EVP_PKEY_derive_set_peer(ctx, peer_key) <= 0 ||
(key_size == 0 && EVP_PKEY_derive(ctx, NULL, &key_size) <= 0)) {
Expand All @@ -1359,6 +1366,14 @@ zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t k
return NULL;
}

#if OPENSSL_VERSION_NUMBER < 0x30000000L
/* Now compare the computed size for DH to mirror OpenSSL 3.0+ behavior. */
if (EVP_PKEY_base_id(key) == EVP_PKEY_DH && requested_key_size > 0 && requested_key_size < key_size) {
EVP_PKEY_CTX_free(ctx);
return NULL;
}
#endif

zend_string *result = zend_string_alloc(key_size, 0);
if (EVP_PKEY_derive(ctx, (unsigned char *)ZSTR_VAL(result), &key_size) <= 0) {
php_openssl_store_errors();
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/php_openssl_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ X509_STORE * php_openssl_setup_verify(zval * calist, uint32_t arg_num);
STACK_OF(X509) * php_openssl_load_all_certs_from_file(
char *cert_file, size_t cert_file_len, uint32_t arg_num);
EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req);
zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t key_size);
zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t requested_key_size);

#define PHP_SSL_REQ_INIT(req) memset(req, 0, sizeof(*req))
#define PHP_SSL_REQ_DISPOSE(req) php_openssl_dispose_config(req)
Expand Down
44 changes: 44 additions & 0 deletions ext/openssl/tests/gh19428.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--TEST--
GH-19428: openssl_pkey_derive() DH with low key_length
--EXTENSIONS--
openssl
--FILE--
<?php

$priv = openssl_pkey_get_private("-----BEGIN PRIVATE KEY-----
MIICJgIBADCCARcGCSqGSIb3DQEDATCCAQgCggEBAJLxRCaZ933uW+AXmabHFDDy
upojBIRlbmQLJZfigDaSA1f9YOTsIv+WwVFTX/J1mtCyx9uBcz0Nt2kmVwxWuc2f
VtCEMPsmLsVXX7xRUFLpyX1Y1IYGBVXQOoOvLWYQjpZgnx47Pkh1Ok1+smffztfC
0DCNt4KorWrbsPcmqBejXHN79KvWFjZmXOksRiNu/Bn76RiqvofC4z8Ri3kHXQG2
197JGZzzFXHadGC3xbkg8UxsNbYhVMKbm0iANfafUH7/hoS9UjAVQYtvwe7YNiW/
HnyfVCrKwcc7sadd8Iphh+3lf5P1AhaQEAMytanrzq9RDXKBxuvpSJifRYasZ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BDtXt0T9+Fx3khHaowjCc7xJZRgZCxg43SbqMWJ9lUg94I7+LTX61Gyv
dtlkbGbtoDOnxeNnN93gwQZngGYZYciu
-----END PUBLIC KEY-----
");

var_dump(openssl_pkey_derive($pub, $priv, 10));

?>
--EXPECT--
bool(false)
2 changes: 2 additions & 0 deletions ext/standard/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ PHP_FUNCTION(dir)
static php_stream* php_dir_get_directory_stream_from_user_arg(php_stream *dir_stream)
{
if (dir_stream == NULL) {
php_error_docref(NULL, E_DEPRECATED,
"Passing null is deprecated, instead the last opened directory stream should be provided");
if (UNEXPECTED(DIRG(default_dir) == NULL)) {
zend_type_error("No resource supplied");
return NULL;
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/dir/closedir_basic-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ rmdir($dir_path);
*** Testing closedir() : basic functionality ***

-- Call closedir() with no arguments: --

Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL
-- Check Directory Handle: --
resource(%d) of type (Unknown)
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/dir/closedir_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ rmdir($dir_path);
*** Testing closedir() : basic functionality ***

-- Call closedir() with no arguments: --

Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL
-- Check Directory Handle: --
resource(%d) of type (Unknown)
Expand Down
3 changes: 2 additions & 1 deletion ext/standard/tests/dir/closedir_without_arg.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ try {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
--EXPECTF--
Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
No resource supplied
12 changes: 12 additions & 0 deletions ext/standard/tests/dir/readdir_basic-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ string(9) "file3.tmp"

-- Call readdir() without $path argument --
resource(%d) of type (stream)

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(9) "file1.tmp"
Expand Down
12 changes: 12 additions & 0 deletions ext/standard/tests/dir/readdir_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ string(9) "file3.tmp"

-- Call readdir() without $path argument --
resource(%d) of type (stream)

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(9) "file1.tmp"
Expand Down
16 changes: 15 additions & 1 deletion ext/standard/tests/dir/readdir_variation6-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ closedir();
$dir_path = __DIR__ . "/私はガラスを食べられますreaddir_variation6";
rmdir($dir_path);
?>
--EXPECT--
--EXPECTF--
*** Testing readdir() : usage variations ***

-- Reading Directory Contents with Previous Handle --
Expand All @@ -72,8 +72,22 @@ string(59) "私はガラスを食べられますreaddir_variation62.tmp"
string(59) "私はガラスを食べられますreaddir_variation63.tmp"

-- Reading Directory Contents with Current Handle (no arguments supplied) --

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(59) "私はガラスを食べられますreaddir_variation61.tmp"
string(59) "私はガラスを食べられますreaddir_variation62.tmp"
string(59) "私はガラスを食べられますreaddir_variation63.tmp"

Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
16 changes: 15 additions & 1 deletion ext/standard/tests/dir/readdir_variation6.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ closedir();
$dir_path = __DIR__ . "/readdir_variation6";
rmdir($dir_path);
?>
--EXPECT--
--EXPECTF--
*** Testing readdir() : usage variations ***

-- Reading Directory Contents with Previous Handle --
Expand All @@ -66,8 +66,22 @@ string(23) "readdir_variation62.tmp"
string(23) "readdir_variation63.tmp"

-- Reading Directory Contents with Current Handle (no arguments supplied) --

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(23) "readdir_variation61.tmp"
string(23) "readdir_variation62.tmp"
string(23) "readdir_variation63.tmp"

Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
12 changes: 12 additions & 0 deletions ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ NULL
bool(true)

-- Read and rewind second directory (no argument supplied) --

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
array(3) {
[0]=>
string(1) "."
Expand All @@ -90,5 +98,9 @@ array(3) {
[2]=>
string(45) "私はガラスを食べられますfile2.tmp"
}

Deprecated: rewinddir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL

Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
bool(true)
Loading