mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
main: Add bailout tests for dir opening on user stream
This commit is contained in:
parent
0992265611
commit
1c67b060c4
7 changed files with 54 additions and 23 deletions
|
@ -9,6 +9,7 @@ function skipFunction($function): bool {
|
|||
/* terminates script */
|
||||
|| $function === 'exit'
|
||||
|| $function === 'die'
|
||||
|| $function === 'zend_trigger_bailout'
|
||||
/* intentionally violate invariants */
|
||||
|| $function === 'zend_create_unterminated_string'
|
||||
|| $function === 'zend_test_array_return'
|
||||
|
|
19
ext/standard/tests/streams/user-stream-dir-open-bailout.phpt
Normal file
19
ext/standard/tests/streams/user-stream-dir-open-bailout.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Bailout (E_ERROR) during UserStream Dir Open
|
||||
--EXTENSIONS--
|
||||
zend_test
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class FailStream {
|
||||
public $context;
|
||||
public function dir_opendir(string $url, int $options) {
|
||||
zend_trigger_bailout();
|
||||
}
|
||||
}
|
||||
stream_wrapper_register('mystream', 'FailStream');
|
||||
opendir('mystream://foo');
|
||||
echo 'Done';
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Bailout in %s on line %d
|
|
@ -1,22 +0,0 @@
|
|||
--TEST--
|
||||
E_ERROR during UserStream Open
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class FailStream {
|
||||
public $context;
|
||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
_some_undefined_function();
|
||||
}
|
||||
}
|
||||
stream_wrapper_register('mystream', 'FailStream');
|
||||
fopen('mystream://foo', 'r');
|
||||
echo 'Done';
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught Error: Call to undefined function _some_undefined_function() in %s%euser-stream-error.php:%d
|
||||
Stack trace:
|
||||
#0 [internal function]: FailStream->stream_open('mystream://foo', 'r', 0, NULL)
|
||||
#1 %s%euser-stream-error.php(%d): fopen('mystream://foo', 'r')
|
||||
#2 {main}
|
||||
thrown in %s%euser-stream-error.php on line %d
|
19
ext/standard/tests/streams/user-stream-open-bailout.phpt
Normal file
19
ext/standard/tests/streams/user-stream-open-bailout.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Bailout (E_ERROR) during UserStream Open
|
||||
--EXTENSIONS--
|
||||
zend_test
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class FailStream {
|
||||
public $context;
|
||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
zend_trigger_bailout();
|
||||
}
|
||||
}
|
||||
stream_wrapper_register('mystream', 'FailStream');
|
||||
fopen('mystream://foo', 'r');
|
||||
echo 'Done';
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Bailout in %s on line %d
|
|
@ -87,6 +87,13 @@ static ZEND_FUNCTION(zend_test_func)
|
|||
EX(func) = NULL;
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(zend_trigger_bailout)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
zend_error(E_ERROR, "Bailout");
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(zend_test_array_return)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
|
|
@ -208,6 +208,8 @@ namespace {
|
|||
case Baz = -1;
|
||||
}
|
||||
|
||||
function zend_trigger_bailout(): never {}
|
||||
|
||||
function zend_test_array_return(): array {}
|
||||
|
||||
/** @genstubs-expose-comment-block
|
||||
|
|
7
ext/zend_test/test_arginfo.h
generated
7
ext/zend_test/test_arginfo.h
generated
|
@ -1,5 +1,8 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 781677c7ada9095af9c964cf86ce6ba63a52a930 */
|
||||
* Stub hash: b767745e4e7be7cb4ba294e238a1b0f63da8479e */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -272,6 +275,7 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
#define arginfo_class_ZendTestNS2_ZendSubNS_Foo_method arginfo_zend_test_void_return
|
||||
|
||||
static ZEND_FUNCTION(zend_trigger_bailout);
|
||||
static ZEND_FUNCTION(zend_test_array_return);
|
||||
static ZEND_FUNCTION(zend_test_nullable_array_return);
|
||||
static ZEND_FUNCTION(zend_test_void_return);
|
||||
|
@ -358,6 +362,7 @@ static ZEND_METHOD(ZendTestNS2_Foo, method);
|
|||
static ZEND_METHOD(ZendTestNS2_ZendSubNS_Foo, method);
|
||||
|
||||
static const zend_function_entry ext_functions[] = {
|
||||
ZEND_FE(zend_trigger_bailout, arginfo_zend_trigger_bailout)
|
||||
ZEND_FE(zend_test_array_return, arginfo_zend_test_array_return)
|
||||
#if (PHP_VERSION_ID >= 80400)
|
||||
ZEND_RAW_FENTRY("zend_test_nullable_array_return", zif_zend_test_nullable_array_return, arginfo_zend_test_nullable_array_return, ZEND_ACC_COMPILE_TIME_EVAL, NULL, "/**\n * \"Lorem ipsum\"\n * @see https://www.php.net\n * @since 8.3\n */")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue