Skip to content

Commit

Permalink
Merge pull request #1914 from sjinks/issue-1912
Browse files Browse the repository at this point in the history
[1.3.0] Fix #1912
  • Loading branch information
Phalcon committed Jan 26, 2014
2 parents 626f01b + 22c2391 commit 5350f1b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
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)

0 comments on commit 5350f1b

Please sign in to comment.