From d248de79f08adecc95fbf1de33433e640e61f4cf Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 4 Jul 2003 14:35:04 +0000 Subject: [PATCH] protect binary contents in cookies --- ChangeLog | 2 ++ libraries/auth/cookie.auth.lib.php3 | 10 +++++++--- user_password.php3 | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 587551a1a..205f59c0c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ $Source$ 2003-07-04 Marc Delisle * libraries/auth/cookie.auth.lib.php3: PHP3 compatibility + * libraries/auth/cookie.auth.lib.php3: sometimes, binary contents in + cookies is not retrieved properly, so protect it with base64_encode() 2003-07-03 Marc Delisle * lang/romanian update, thanks to Valics Lehel diff --git a/libraries/auth/cookie.auth.lib.php3 b/libraries/auth/cookie.auth.lib.php3 index f12d06f5f..4c1ae1e0d 100644 --- a/libraries/auth/cookie.auth.lib.php3 +++ b/libraries/auth/cookie.auth.lib.php3 @@ -396,7 +396,7 @@ if (uname.value == '') { // The user wants to be logged out -> delete password cookie if (!empty($old_usr)) { - setcookie('pma_cookie_password', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); + setcookie('pma_cookie_password', base64_encode(''), 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); } // The user just logged in @@ -434,6 +434,7 @@ if (uname.value == '') { else { $from_cookie = FALSE; } + $PHP_AUTH_PW = base64_decode($PHP_AUTH_PW); $PHP_AUTH_PW = PMA_blowfish_decrypt($PHP_AUTH_PW,$GLOBALS['cfg']['Server']['blowfish_secret']); if ($PHP_AUTH_PW == "\xff(blank)") { @@ -501,9 +502,12 @@ if (uname.value == '') { time() + (60 * 60 * 24 * 30), $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); + // Duration = till the browser is closed for password + // Some binary contents are now retrieved properly when stored + // as a cookie, so we base64_encode() setcookie('pma_cookie_password', - PMA_blowfish_encrypt(((!empty($cfg['Server']['password'])) ? $cfg['Server']['password'] : "\xff(blank)"), $GLOBALS['cfg']['Server']['blowfish_secret']), + base64_encode(PMA_blowfish_encrypt(((!empty($cfg['Server']['password'])) ? $cfg['Server']['password'] : "\xff(blank)"), $GLOBALS['cfg']['Server']['blowfish_secret'])), 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); @@ -541,7 +545,7 @@ if (uname.value == '') { global $conn_error; // Deletes password cookie and displays the login form - setcookie('pma_cookie_password', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); + setcookie('pma_cookie_password', base64_encode(''), 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); if (PMA_mysql_error()) { $conn_error = PMA_mysql_error(); diff --git a/user_password.php3 b/user_password.php3 index 7658a8fbd..b58e8a7e9 100644 --- a/user_password.php3 +++ b/user_password.php3 @@ -55,7 +55,7 @@ if (isset($nopass)) { // Changes password cookie if required if ($cfg['Server']['auth_type'] == 'cookie') { - setcookie('pma_cookie_password', PMA_blowfish_encrypt($pma_pw,$GLOBALS['cfg']['Server']['blowfish_secret']), 0, $cookie_path, '', $is_https); + setcookie('pma_cookie_password', base64_encode(PMA_blowfish_encrypt($pma_pw,$GLOBALS['cfg']['Server']['blowfish_secret'])), 0, $cookie_path, '', $is_https); } // end if // For http auth. mode, the "back" link will also enforce new // authentication