Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.3.0] Fix #1912 #1914

Merged
merged 4 commits into from Jan 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
- Added Phalcon\Security::computeHmac() (#1347)
- Bug fixes (#1347)
- Constant-time string comparison in Phalcon\Security::checkHash() to prevent timing attacks (#1755)
- Phalcon\Security::checkHash() now correctly handles non-bcrypt hashes (#1912)
- Phalcon\Session:
- Fix Phalcon\Session\Bag::remove() (#1637)
- Phalcon\Session\Adapter::get() may optionally remove the data from session (#1358)
Expand Down
6 changes: 3 additions & 3 deletions ext/dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,10 @@ static int phalcon_dispatcher_fire_event(zval *return_value, zval *mgr, const ch
else {
status2 = phalcon_call_method_params(NULL, NULL, source, SL("_handleexception"), zend_inline_hash_func(SS("_handleexception")) TSRMLS_CC, 1, exception);
}
}

if (FAILURE == status2) {
status = FAILURE;
if (FAILURE == status2) {
status = FAILURE;
}
}

ZVAL_NULL(event_name);
Expand Down
4 changes: 3 additions & 1 deletion ext/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,11 @@ PHP_METHOD(Phalcon_Security, checkHash){
}

zval_ptr_dtor(&hash);
RETURN_BOOL(check == 0);
}

RETURN_BOOL(check == 0);
zval_ptr_dtor(&hash);
RETURN_FALSE;
}

/**
Expand Down
17 changes: 17 additions & 0 deletions ext/tests/issue-1912.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Security::checkHash returns true when using with a non-bcrypt hash
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$di = new \Phalcon\DI\FactoryDefault();
$di->setShared('security', function () {
$security = new \Phalcon\Security();
$security->setWorkFactor(12);
return $security;
});

var_dump($di->get('security')->checkHash('not jelly beans', 'cb7d86ece76c57eac5ed18420ca67ea0'));
?>
--EXPECT--
bool(false)