From fb061aaecead8248d1a5cc43cc9593832d7bbdc0 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Tue, 08 Mar 2011 03:07:43 -0500 Subject: [PATCH] Use PHPs session_regenerte_id() instead of using (unreliable) mt_rand() function (#1486281) --- CHANGELOG | 1 + program/include/rcube_session.php | 16 ++-------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 90ce0ab..1336e96 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Get around unreliable rand() and mt_rand() in session ID generation (#1486281) - Fix some emails are not shown using Cyrus IMAP (#1487820) - Fix handling of mime-encoded words with non-integral number of octets in a word (#1487801) - New config option for custom logo diff --git a/program/include/rcube_session.php b/program/include/rcube_session.php index 2bd663c..0fc4442 100644 --- a/program/include/rcube_session.php +++ b/program/include/rcube_session.php @@ -212,20 +212,8 @@ $this->destroy(session_id()); $this->vars = false; - $randval = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - - for ($random = '', $i=1; $i <= 32; $i++) { - $random .= substr($randval, mt_rand(0,(strlen($randval) - 1)), 1); - } - - // use md5 value for id - $this->key = md5($random); - session_id($this->key); - - $cookie = session_get_cookie_params(); - $lifetime = $cookie['lifetime'] ? time() + $cookie['lifetime'] : 0; - - rcmail::setcookie(session_name(), $this->key, $lifetime); + session_regenerate_id(false); + $this->key = session_id(); return true; } -- Gitblit v1.9.1