From b06b007c57c6d19cfe7d6e2c22ef97076eeb3e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 26 Aug 2022 10:33:38 +0200 Subject: [PATCH] Fix tests --- ext/random/engine_mt19937.c | 1 + ext/random/tests/03_randomizer/gh_9186_unserialize.phpt | 4 ++-- ext/spl/tests/bug70155.phpt | 2 ++ ext/spl/tests/bug74669.phpt | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/random/engine_mt19937.c b/ext/random/engine_mt19937.c index 11f97d35291a2..a2aed76a39d76 100644 --- a/ext/random/engine_mt19937.c +++ b/ext/random/engine_mt19937.c @@ -366,6 +366,7 @@ PHP_METHOD(Random_Engine_Mt19937, __unserialize) } object_properties_load(&engine->std, Z_ARRVAL_P(t)); if (EG(exception)) { + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(engine->std.ce->name)); RETURN_THROWS(); } diff --git a/ext/random/tests/03_randomizer/gh_9186_unserialize.phpt b/ext/random/tests/03_randomizer/gh_9186_unserialize.phpt index e11d4d33a45c0..fe1acb2f74be4 100644 --- a/ext/random/tests/03_randomizer/gh_9186_unserialize.phpt +++ b/ext/random/tests/03_randomizer/gh_9186_unserialize.phpt @@ -5,10 +5,10 @@ Fix GH-9186 @strict-properties can be bypassed using unserialization try { unserialize('O:17:"Random\Randomizer":1:{i:0;a:2:{s:3:"foo";N;s:6:"engine";O:32:"Random\Engine\Xoshiro256StarStar":2:{i:0;a:0:{}i:1;a:4:{i:0;s:16:"7520fbc2d6f8de46";i:1;s:16:"84d2d2b9d7ba0a34";i:2;s:16:"d975f36db6490b32";i:3;s:16:"c19991ee16785b94";}}}}'); -} catch (Error $error) { +} catch (Exception $error) { echo $error->getMessage() . "\n"; } ?> --EXPECT-- -Cannot create dynamic property Random\Randomizer::$foo +Invalid serialization data for Random\Randomizer object diff --git a/ext/spl/tests/bug70155.phpt b/ext/spl/tests/bug70155.phpt index 0aa246cc2388f..a609205aca279 100644 --- a/ext/spl/tests/bug70155.phpt +++ b/ext/spl/tests/bug70155.phpt @@ -9,6 +9,8 @@ $data = unserialize($exploit); var_dump($data); ?> --EXPECTF-- +Deprecated: Creation of dynamic property ArrayObject::$0 is deprecated in %s on line %d + Fatal error: Uncaught InvalidArgumentException: Overloaded object of type DateInterval is not compatible with ArrayObject in %s Stack trace: %s diff --git a/ext/spl/tests/bug74669.phpt b/ext/spl/tests/bug74669.phpt index 0966a4cf27e15..597e694296d26 100644 --- a/ext/spl/tests/bug74669.phpt +++ b/ext/spl/tests/bug74669.phpt @@ -105,6 +105,8 @@ object(SelfArray)#9 (1) { string(3) "bar" } string(77) "O:9:"SelfArray":4:{i:0;i:16777216;i:1;N;i:2;a:1:{s:3:"foo";s:3:"bar";}i:3;N;}" + +Deprecated: Creation of dynamic property SelfArray::$foo is deprecated in %s on line %d object(SelfArray)#9 (1) { ["foo"]=> string(3) "bar"