|
@@ -415,6 +415,14 @@ class Zend_Session extends Zend_Session_Abstract
|
|
|
*/
|
|
*/
|
|
|
public static function start($options = false)
|
|
public static function start($options = false)
|
|
|
{
|
|
{
|
|
|
|
|
+ // Check to see if we've been passed an invalid session ID
|
|
|
|
|
+ if ( self::getId() && !self::_checkId(self::getId()) ) {
|
|
|
|
|
+ // Generate a valid, temporary replacement
|
|
|
|
|
+ self::setId(md5(self::getId()));
|
|
|
|
|
+ // Force a regenerate after session is started
|
|
|
|
|
+ self::$_regenerateIdState = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (self::$_sessionStarted && self::$_destroyed) {
|
|
if (self::$_sessionStarted && self::$_destroyed) {
|
|
|
require_once 'Zend/Session/Exception.php';
|
|
require_once 'Zend/Session/Exception.php';
|
|
|
throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
|
|
throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
|
|
@@ -499,6 +507,26 @@ class Zend_Session extends Zend_Session_Abstract
|
|
|
self::_processStartupMetadataGlobal();
|
|
self::_processStartupMetadataGlobal();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Perform a hash-bits check on the session ID
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $id Session ID
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ protected static function _checkId($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $hashBitsPerChar = ini_get('session.hash_bits_per_character');
|
|
|
|
|
+ if (!$hashBitsPerChar) {
|
|
|
|
|
+ $hashBitsPerChar = 5; // the default value
|
|
|
|
|
+ }
|
|
|
|
|
+ switch($hashBitsPerChar) {
|
|
|
|
|
+ case 4: $pattern = '^[0-9a-f]*$'; break;
|
|
|
|
|
+ case 5: $pattern = '^[0-9a-v]*$'; break;
|
|
|
|
|
+ case 6: $pattern = '^[0-9a-zA-Z-,]*$'; break;
|
|
|
|
|
+ }
|
|
|
|
|
+ return preg_match('#'.$pattern.'#', $id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* _processGlobalMetadata() - this method initizes the sessions GLOBAL
|
|
* _processGlobalMetadata() - this method initizes the sessions GLOBAL
|