com php-src: Fixed bug #68063 Empty session IDs do still start sessions: ext/session/session.c ext/session/tests/bug68063.phpt

From: Date: Tue, 03 Feb 2015 04:38:49 +0000
Subject: com php-src: Fixed bug #68063 Empty session IDs do still start sessions: ext/session/session.c ext/session/tests/bug68063.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84578@lists.php.net to get a copy of this message
Commit: 853ae39d6ea6a4d2ce95098744e481a1e8573ad8 Author: Yasuo Ohgaki <yohgaki@php.net> Tue, 3 Feb 2015 13:38:49 +0900 Parents: 17beba686e69a6f0dae9db9548582c34df81ceef Branches: PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=853ae39d6ea6a4d2ce95098744e481a1e8573ad8 Log: Fixed bug #68063 Empty session IDs do still start sessions Bugs: https://bugs.php.net/68063 Changed paths: M ext/session/session.c A ext/session/tests/bug68063.phpt Diff: diff --git a/ext/session/session.c b/ext/session/session.c index 2c4d5c0..9b60930 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -2053,6 +2053,11 @@ static PHP_FUNCTION(session_decode) static PHP_FUNCTION(session_start) { /* skipping check for non-zero args for performance reasons here ?*/ + if (PS(id) && !strlen(PS(id))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot start session with empty session ID"); + RETURN_FALSE; + } + php_session_start(TSRMLS_C); if (PS(session_status) != php_session_active) { diff --git a/ext/session/tests/bug68063.phpt b/ext/session/tests/bug68063.phpt new file mode 100644 index 0000000..d3da470 --- /dev/null +++ b/ext/session/tests/bug68063.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #68063 (Empty session IDs do still start sessions) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +--FILE-- +<?php +// Could also be set with a cookie like "PHPSESSID=; path=/" +session_id(''); + +// Will still start the session and return true +var_dump(session_start()); + +// Returns an empty string +var_dump(session_id()); +?> +--EXPECTF-- +Warning: session_start(): Cannot start session with empty session ID in %s on line %d +bool(false) +string(0) ""

« previous php.cvs (#84578) next »