1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Removed impossible paths from session_decode and session_encode (#13796)

This commit is contained in:
Jorg Adam Sowa
2024-03-24 20:20:42 +01:00
committed by GitHub
parent ab8e0b7bf8
commit f69d540541
2 changed files with 29 additions and 8 deletions

View File

@@ -247,10 +247,7 @@ static void php_session_track_init(void) /* {{{ */
static zend_string *php_session_encode(void) /* {{{ */
{
IF_SESSION_VARS() {
if (!PS(serializer)) {
php_error_docref(NULL, E_WARNING, "Unknown session.serialize_handler. Failed to encode session object");
return NULL;
}
ZEND_ASSERT(PS(serializer));
return PS(serializer)->encode();
} else {
php_error_docref(NULL, E_WARNING, "Cannot encode non-existent session");
@@ -268,10 +265,7 @@ static ZEND_COLD void php_session_cancel_decode(void)
static zend_result php_session_decode(zend_string *data) /* {{{ */
{
if (!PS(serializer)) {
php_error_docref(NULL, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object");
return FAILURE;
}
ZEND_ASSERT(PS(serializer));
zend_result result = SUCCESS;
zend_try {
if (PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data)) == FAILURE) {

View File

@@ -0,0 +1,27 @@
--TEST--
Test session_decode() function : error functionality
--EXTENSIONS--
session
--SKIPIF--
<?php include('skipif.inc'); ?>
--INI--
session.serialize_handler = wrong_handler
--FILE--
<?php
ob_start();
session_start();
ini_set('session.serialize_handler', 'wrong_handler');
var_dump(session_decode(''));
echo "Done";
ob_end_flush();
?>
--EXPECTF--
Warning: session_start(): Cannot find session serialization handler "wrong_handler" - session startup failed in %s on line 4
Warning: ini_set(): Serialization handler "wrong_handler" cannot be found in %s on line 5
Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line 6
bool(false)
Done