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

ValueError on null byte in session_name() (#15286)

This commit is contained in:
Jorg Adam Sowa
2024-08-11 14:26:54 +02:00
committed by GitHub
parent cb8df212aa
commit 6bf7b7220d
3 changed files with 23 additions and 13 deletions

View File

@@ -1875,13 +1875,13 @@ PHP_FUNCTION(session_get_cookie_params)
}
/* }}} */
/* {{{ Return the current session name. If newname is given, the session name is replaced with newname */
/* {{{ Return the current session name. If new name is given, the session name is replaced with new name */
PHP_FUNCTION(session_name)
{
zend_string *name = NULL;
zend_string *ini_name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &name) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|P!", &name) == FAILURE) {
RETURN_THROWS();
}

View File

@@ -15,12 +15,6 @@ ob_start();
echo "*** Testing session_name() : variation ***\n";
var_dump(session_name("\0"));
var_dump(session_start());
var_dump(session_name());
var_dump(session_destroy());
var_dump(session_name());
var_dump(session_name("\t"));
var_dump(session_start());
var_dump(session_name());
@@ -39,11 +33,6 @@ ob_end_flush();
--EXPECTF--
*** Testing session_name() : variation ***
string(9) "PHPSESSID"
bool(true)
string(9) "PHPSESSID"
bool(true)
string(9) "PHPSESSID"
string(9) "PHPSESSID"
Warning: session_start(): session.name cannot contain any of the following '=,;.[ \t\r\n\013\014' in %s on line %d
bool(true)

View File

@@ -0,0 +1,21 @@
--TEST--
Test session_name() function : null byte in session name
--EXTENSIONS--
session
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
try {
var_dump(session_name("AB\0CD"));
var_dump(session_start());
} catch (ValueError $e) {
echo $e->getMessage(). "\n";
}
echo "Done";
?>
--EXPECT--
session_name(): Argument #1 ($name) must not contain any null bytes
Done