Skip to content

Commit

Permalink
Merge pull request #184 from Spuds/Exact
Browse files Browse the repository at this point in the history
Per board discussions, change a few comparitors to === for good measure
  • Loading branch information
norv committed Feb 27, 2013
2 parents 5b32821 + 62b0e5d commit 169c3d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions sources/Security.php
Expand Up @@ -626,7 +626,7 @@ function checkSession($type = 'post', $from_action = '', $is_fatal = true)
}

// How about $_GET['sesc']?
elseif ($type == 'get')
elseif ($type === 'get')
{
$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
if ($check !== $sc)
Expand Down Expand Up @@ -732,9 +732,8 @@ function checkConfirm($action)
{
global $modSettings;

if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) === $_SESSION['confirm_' . $action])
return true;

else
{
$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
Expand Down Expand Up @@ -801,7 +800,7 @@ function validateToken($action, $type = 'post', $reset = true)
4. Match that result against what is in the session.
5. If it matchs, success, otherwise we fallout.
*/
if (isset($_SESSION['token'][$type . '-' . $action], $GLOBALS['_' . strtoupper($type)][$_SESSION['token'][$type . '-' . $action][0]]) && md5($GLOBALS['_' . strtoupper($type)][$_SESSION['token'][$type . '-' . $action][0]] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['token'][$type . '-' . $action][1])
if (isset($_SESSION['token'][$type . '-' . $action], $GLOBALS['_' . strtoupper($type)][$_SESSION['token'][$type . '-' . $action][0]]) && md5($GLOBALS['_' . strtoupper($type)][$_SESSION['token'][$type . '-' . $action][0]] . $_SERVER['HTTP_USER_AGENT']) === $_SESSION['token'][$type . '-' . $action][1])
{
// Invalidate this token now.
unset($_SESSION['token'][$type . '-' . $action]);
Expand Down
4 changes: 2 additions & 2 deletions sources/admin/ManageLanguages.php
Expand Up @@ -298,13 +298,13 @@ function DownloadLanguage()
$context_data['writable'] = true;

// Finally, do we actually think the content has changed?
if ($file['size'] == filesize(BOARDDIR . '/' . $file['filename']) && $file['md5'] == md5_file(BOARDDIR . '/' . $file['filename']))
if ($file['size'] == filesize(BOARDDIR . '/' . $file['filename']) && $file['md5'] === md5_file(BOARDDIR . '/' . $file['filename']))
{
$context_data['exists'] = 'same';
$context_data['default_copy'] = false;
}
// Attempt to discover newline character differences.
elseif ($file['md5'] == md5(preg_replace("~[\r]?\n~", "\r\n", file_get_contents(BOARDDIR . '/' . $file['filename']))))
elseif ($file['md5'] === md5(preg_replace("~[\r]?\n~", "\r\n", file_get_contents(BOARDDIR . '/' . $file['filename']))))
{
$context_data['exists'] = 'same';
$context_data['default_copy'] = false;
Expand Down
4 changes: 2 additions & 2 deletions sources/controllers/Reminder.controller.php
Expand Up @@ -251,7 +251,7 @@ function action_setpassword2()
fatal_lang_error('profile_error_password_' . $passwordError, false);

// Quit if this code is not right.
if (empty($_POST['code']) || substr($realCode, 0, 10) != substr(md5($_POST['code']), 0, 10))
if (empty($_POST['code']) || substr($realCode, 0, 10) !== substr(md5($_POST['code']), 0, 10))
{
// Stop brute force attacks like this.
validatePasswordFlood($_POST['u'], $flood_value, false);
Expand Down Expand Up @@ -360,7 +360,7 @@ function action_secret2()
$smcFunc['db_free_result']($request);

// Check if the secret answer is correct.
if ($row['secret_question'] == '' || $row['secret_answer'] == '' || md5($_POST['secret_answer']) != $row['secret_answer'])
if ($row['secret_question'] == '' || $row['secret_answer'] == '' || md5($_POST['secret_answer']) !== $row['secret_answer'])
{
log_error(sprintf($txt['reminder_error'], $row['member_name']), 'user');
fatal_lang_error('incorrect_answer', false);
Expand Down

0 comments on commit 169c3d2

Please sign in to comment.