Skip to content

Commit

Permalink
Use PHPs session_regenerte_id() instead of using (unreliable) mt_rand…
Browse files Browse the repository at this point in the history
…() function (#1486281)
  • Loading branch information
thomascube committed Mar 8, 2011
1 parent 6f6efa2 commit fb061aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 2 additions & 14 deletions program/include/rcube_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,8 @@ public function regenerate_id()
$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;
}
Expand Down

0 comments on commit fb061aa

Please sign in to comment.