mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Merge branch 'master' into sccp
* master: Resources should be closed during object destructioin, not during freeing. Guard against AppVeyor losing deps issue increase poll timeout as false positives mitigation Value of EG(user_exception_handler) should't relive request boundary sodium ext: remove function names before exception messages sodium ext: update the crypto_kx_*() API to the libsodium one Revert "fix macro redifinitions"
This commit is contained in:
commit
2722dbfdf5
11 changed files with 356 additions and 216 deletions
|
@ -154,6 +154,7 @@ void init_executor(void) /* {{{ */
|
|||
EG(ticks_count) = 0;
|
||||
|
||||
ZVAL_UNDEF(&EG(user_error_handler));
|
||||
ZVAL_UNDEF(&EG(user_exception_handler));
|
||||
|
||||
EG(current_execute_data) = NULL;
|
||||
|
||||
|
|
|
@ -22,6 +22,13 @@ echo Updating dependencies in %DEPS_DIR%
|
|||
cmd /c phpsdk_deps --update --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR% --crt %PHP_BUILD_CRT%
|
||||
if %errorlevel% neq 0 exit /b 3
|
||||
|
||||
rem Something went wrong, most likely when concurrent builds were to fetch deps
|
||||
rem updates. It might be, that some locking mechanism is needed.
|
||||
if not exist "%DEPS_DIR%" (
|
||||
cmd /c phpsdk_deps --update --force --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR%
|
||||
)
|
||||
if %errorlevel% neq 0 exit /b 3
|
||||
|
||||
cmd /c buildconf.bat --force
|
||||
if %errorlevel% neq 0 exit /b 3
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ if (!$IS_MYSQLND)
|
|||
|
||||
function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) {
|
||||
|
||||
if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
|
||||
if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 2000)))
|
||||
printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
|
||||
$offset, $exp_ready, $tmp);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -59,7 +59,12 @@ PHP_FUNCTION(sodium_crypto_generichash);
|
|||
PHP_FUNCTION(sodium_crypto_generichash_final);
|
||||
PHP_FUNCTION(sodium_crypto_generichash_init);
|
||||
PHP_FUNCTION(sodium_crypto_generichash_update);
|
||||
PHP_FUNCTION(sodium_crypto_kx);
|
||||
PHP_FUNCTION(sodium_crypto_kx_client_session_keys);
|
||||
PHP_FUNCTION(sodium_crypto_kx_keypair);
|
||||
PHP_FUNCTION(sodium_crypto_kx_publickey);
|
||||
PHP_FUNCTION(sodium_crypto_kx_secretkey);
|
||||
PHP_FUNCTION(sodium_crypto_kx_seed_keypair);
|
||||
PHP_FUNCTION(sodium_crypto_kx_server_session_keys);
|
||||
PHP_FUNCTION(sodium_crypto_pwhash);
|
||||
PHP_FUNCTION(sodium_crypto_pwhash_str);
|
||||
PHP_FUNCTION(sodium_crypto_pwhash_str_verify);
|
||||
|
@ -96,15 +101,9 @@ PHP_FUNCTION(sodium_add);
|
|||
PHP_FUNCTION(sodium_memcmp);
|
||||
PHP_FUNCTION(sodium_memzero);
|
||||
|
||||
#ifndef crypto_kx_BYTES
|
||||
#define crypto_kx_BYTES crypto_scalarmult_BYTES
|
||||
#endif
|
||||
#ifndef crypto_kx_PUBLICKEYBYTES
|
||||
#define crypto_kx_PUBLICKEYBYTES crypto_scalarmult_SCALARBYTES
|
||||
#endif
|
||||
#ifndef crypto_kx_SECRETKEYBYTES
|
||||
#define crypto_kx_SECRETKEYBYTES crypto_scalarmult_SCALARBYTES
|
||||
#endif
|
||||
|
||||
#endif /* PHP_LIBSODIUM_H */
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ var_dump(sodium_crypto_auth_verify($badmac, $msg, $key));
|
|||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
crypto_auth(): key must be CRYPTO_AUTH_KEYBYTES bytes
|
||||
key must be CRYPTO_AUTH_KEYBYTES bytes
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
|
|
@ -142,7 +142,7 @@ bool(true)
|
|||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
crypto_box(): keypair size should be CRYPTO_BOX_KEYPAIRBYTES bytes
|
||||
keypair size should be CRYPTO_BOX_KEYPAIRBYTES bytes
|
||||
bool(true)
|
||||
string(17) "Hi, this is Alice"
|
||||
string(21) "Hi Alice! This is Bob"
|
||||
|
|
|
@ -4,34 +4,31 @@ Check for libsodium-based key exchange
|
|||
<?php if (!extension_loaded("sodium")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$client_secretkey = sodium_hex2bin("8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a");
|
||||
$client_publickey = sodium_crypto_box_publickey_from_secretkey($client_secretkey);
|
||||
$client_seed = sodium_hex2bin('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef');
|
||||
$client_keypair = sodium_crypto_kx_seed_keypair($client_seed);
|
||||
$server_seed = sodium_hex2bin('f123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde0');
|
||||
$server_keypair = sodium_crypto_kx_seed_keypair($server_seed);
|
||||
|
||||
$server_secretkey = sodium_hex2bin("948f00e90a246fb5909f8648c2ac6f21515771235523266439e0d775ba0c3671");
|
||||
$server_publickey = sodium_crypto_box_publickey_from_secretkey($server_secretkey);
|
||||
var_dump(sodium_bin2hex($client_keypair));
|
||||
var_dump(sodium_bin2hex($server_keypair));
|
||||
|
||||
$shared_key_computed_by_client =
|
||||
sodium_crypto_kx($client_secretkey, $server_publickey,
|
||||
$client_publickey, $server_publickey);
|
||||
$client_session_keys =
|
||||
sodium_crypto_kx_client_session_keys($client_keypair,
|
||||
sodium_crypto_kx_publickey($server_keypair));
|
||||
|
||||
$shared_key_computed_by_server =
|
||||
sodium_crypto_kx($server_secretkey, $client_publickey,
|
||||
$client_publickey, $server_publickey);
|
||||
$server_session_keys =
|
||||
sodium_crypto_kx_server_session_keys($server_keypair,
|
||||
sodium_crypto_kx_publickey($client_keypair));
|
||||
|
||||
var_dump(sodium_bin2hex($shared_key_computed_by_client));
|
||||
var_dump(sodium_bin2hex($shared_key_computed_by_server));
|
||||
try {
|
||||
sodium_crypto_kx(
|
||||
substr($client_secretkey, 1),
|
||||
$server_publickey,
|
||||
$client_publickey,
|
||||
$server_publickey
|
||||
);
|
||||
} catch (SodiumException $ex) {
|
||||
var_dump(true);
|
||||
}
|
||||
var_dump(sodium_bin2hex($client_session_keys[0]));
|
||||
var_dump(sodium_bin2hex($server_session_keys[1]));
|
||||
var_dump(sodium_bin2hex($client_session_keys[1]));
|
||||
var_dump(sodium_bin2hex($server_session_keys[0]));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(64) "509a1580c2ee30c565317e29e0fea0b1c232e0ef3a7871d91dc64814b19a3bd2"
|
||||
string(64) "509a1580c2ee30c565317e29e0fea0b1c232e0ef3a7871d91dc64814b19a3bd2"
|
||||
bool(true)
|
||||
string(128) "b85c84f9828524519d32b97cd3dda961fdba2dbf407ae4601e2129229aa463c224eaf70f070a925d6d5176f20495d4d90867624d9a10379e2a9aef0955c9bf4e"
|
||||
string(128) "016e814c32b8b66225a403db45bf50fdd1966fb802c3115bf8aa90738c6a02de420ccdb534930fed9aaff12188bedc76e66251f399c404f2e4a15678fd4a484a"
|
||||
string(64) "99a430e61d718b71979ebcea6735c4648bc828cfb456890aeda4b628b77d5ac7"
|
||||
string(64) "99a430e61d718b71979ebcea6735c4648bc828cfb456890aeda4b628b77d5ac7"
|
||||
string(64) "876bef865a5ab3f4ae569ea5aaefe5014c3ec22a558c0a2f0274aa9985bd328d"
|
||||
string(64) "876bef865a5ab3f4ae569ea5aaefe5014c3ec22a558c0a2f0274aa9985bd328d"
|
||||
|
|
|
@ -14,7 +14,7 @@ do_memzero($x);
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught SodiumException: memzero: a PHP string is required in %s:%d
|
||||
Fatal error: Uncaught SodiumException: a PHP string is required in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): sodium_memzero()
|
||||
#1 %s(%d): do_memzero()
|
||||
|
|
|
@ -43,12 +43,12 @@ var_dump($str, $str2);
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
increment(): a PHP string is required
|
||||
a PHP string is required
|
||||
string(3) "bbc"
|
||||
string(3) "abc"
|
||||
string(3) "bbc"
|
||||
string(3) "abc"
|
||||
add(): PHP strings are required
|
||||
PHP strings are required
|
||||
string(3) "cbc"
|
||||
string(3) "abc"
|
||||
string(3) "cbc"
|
||||
|
|
|
@ -72,6 +72,36 @@ static void spl_filesystem_file_free_line(spl_filesystem_object *intern) /* {{{
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
static void spl_filesystem_object_destroy_object(zend_object *object) /* {{{ */
|
||||
{
|
||||
spl_filesystem_object *intern = spl_filesystem_from_obj(object);
|
||||
|
||||
zend_objects_destroy_object(object);
|
||||
|
||||
switch(intern->type) {
|
||||
case SPL_FS_DIR:
|
||||
if (intern->u.dir.dirp) {
|
||||
php_stream_close(intern->u.dir.dirp);
|
||||
intern->u.dir.dirp = NULL;
|
||||
}
|
||||
break;
|
||||
case SPL_FS_FILE:
|
||||
if (intern->u.file.stream) {
|
||||
/*
|
||||
if (intern->u.file.zcontext) {
|
||||
zend_list_delref(Z_RESVAL_P(intern->zcontext));
|
||||
}
|
||||
*/
|
||||
if (!intern->u.file.stream->is_persistent) {
|
||||
php_stream_close(intern->u.file.stream);
|
||||
} else {
|
||||
php_stream_pclose(intern->u.file.stream);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
static void spl_filesystem_object_free_storage(zend_object *object) /* {{{ */
|
||||
{
|
||||
spl_filesystem_object *intern = spl_filesystem_from_obj(object);
|
||||
|
@ -92,26 +122,12 @@ static void spl_filesystem_object_free_storage(zend_object *object) /* {{{ */
|
|||
case SPL_FS_INFO:
|
||||
break;
|
||||
case SPL_FS_DIR:
|
||||
if (intern->u.dir.dirp) {
|
||||
php_stream_close(intern->u.dir.dirp);
|
||||
intern->u.dir.dirp = NULL;
|
||||
}
|
||||
if (intern->u.dir.sub_path) {
|
||||
efree(intern->u.dir.sub_path);
|
||||
}
|
||||
break;
|
||||
case SPL_FS_FILE:
|
||||
if (intern->u.file.stream) {
|
||||
/*
|
||||
if (intern->u.file.zcontext) {
|
||||
zend_list_delref(Z_RESVAL_P(intern->zcontext));
|
||||
}
|
||||
*/
|
||||
if (!intern->u.file.stream->is_persistent) {
|
||||
php_stream_close(intern->u.file.stream);
|
||||
} else {
|
||||
php_stream_pclose(intern->u.file.stream);
|
||||
}
|
||||
if (intern->u.file.open_mode) {
|
||||
efree(intern->u.file.open_mode);
|
||||
}
|
||||
|
@ -3108,7 +3124,7 @@ PHP_MINIT_FUNCTION(spl_directory)
|
|||
spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
|
||||
spl_filesystem_object_handlers.cast_object = spl_filesystem_object_cast;
|
||||
spl_filesystem_object_handlers.get_debug_info = spl_filesystem_object_get_debug_info;
|
||||
spl_filesystem_object_handlers.dtor_obj = zend_objects_destroy_object;
|
||||
spl_filesystem_object_handlers.dtor_obj = spl_filesystem_object_destroy_object;
|
||||
spl_filesystem_object_handlers.free_obj = spl_filesystem_object_free_storage;
|
||||
spl_ce_SplFileInfo->serialize = zend_class_serialize_deny;
|
||||
spl_ce_SplFileInfo->unserialize = zend_class_unserialize_deny;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue