Commit: 82b0e8be99065b61b622df21bbc7494d2fbca3cd Author: Yasuo Ohgaki <[email protected]> Tue, 25 Jun 2013 20:09:10 +0900 Committer: Stanislav Malyshev <[email protected]> Sun, 4 Aug 2013 16:36:53 -0700 Parents: 25e8fcc88fa20dc9d4c47184471003f436927cde Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=82b0e8be99065b61b622df21bbc7494d2fbca3cd Log: Strict session. Detect session id collision Changed paths: M ext/session/mod_files.c M ext/session/mod_mm.c Diff: diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index e9dc25a..6beee09 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -459,9 +459,22 @@ PS_GC_FUNC(files) PS_CREATE_SID_FUNC(files) { char *sid; + int maxfail = 3; PS_FILES_DATA; - sid = php_session_create_id((void **)&data, newlen TSRMLS_CC); + do { + sid = php_session_create_id((void **)&data, newlen TSRMLS_CC); + /* Check collision */ + if (ps_files_key_exists(data, sid TSRMLS_CC) == SUCCESS) { + if (sid) { + efree(sid); + sid = NULL; + } + if (!(maxfail--)) { + return NULL; + } + } + } while(!sid); return sid; } diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c index 7ca9083..69c0da7 100644 --- a/ext/session/mod_mm.c +++ b/ext/session/mod_mm.c @@ -479,9 +479,22 @@ PS_GC_FUNC(mm) PS_CREATE_SID_FUNC(mm) { char *sid; + int maxfail = 3; PS_MM_DATA; - sid = php_session_create_id((void **)&data, newlen TSRMLS_CC); + do { + sid = php_session_create_id((void **)&data, newlen TSRMLS_CC); + /* Check collision */ + if (ps_mm_key_exists(data, sid TSRMLS_CC) == SUCCESS) { + if (sid) { + efree(sid); + sid = NULL; + } + if (!(maxfail--)) { + return NULL; + } + } + } while(!sid); return sid; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
