com php-src: More error checking, and some cleaning up for password.c: ext/standard/password.c
| From: | Anthony Ferrara | Date: | Mon, 25 Jun 2012 12:50:39 +0000 |
| Subject: | com php-src: More error checking, and some cleaning up for password.c: ext/standard/password.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-70389@lists.php.net to get a copy of this message | ||
Commit: 618f2629567ca3a3d1817ca9c4c62339fb5fb886
Author: Anthony Ferrara <ircmaxell@ircmaxell.com> Mon, 25 Jun 2012 08:50:39 -0400
Parents: 18d3bd9481c470d241c492eb39a93bd071a77c4e
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=618f2629567ca3a3d1817ca9c4c62339fb5fb886
Log:
More error checking, and some cleaning up for password.c
Changed paths:
M ext/standard/password.c
Diff:
diff --git a/ext/standard/password.c b/ext/standard/password.c
index f6d8048..013dab7 100644
--- a/ext/standard/password.c
+++ b/ext/standard/password.c
@@ -21,10 +21,6 @@
#include <stdlib.h>
#include "php.h"
-#if HAVE_CRYPT
-#include "php_crypt.h"
-#endif
-
#include "ext/hash/php_hash.h"
#include "php_password.h"
#include "php_rand.h"
@@ -121,7 +117,7 @@ static int php_password_make_salt(int length, int raw, char *ret TSRMLS_DC)
char *result;
result = emalloc(length + 1);
if (php_password_salt_to64(buffer, raw_length, length, result) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Generated salt too short");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Generated salt too short");
efree(buffer);
efree(result);
return FAILURE;
@@ -139,6 +135,12 @@ PHP_FUNCTION(password_verify)
{
zval *password, *hash, *ret;
int status = 0, i;
+ zend_function *func_ptr;
+
+ if (!PHP_PASSWORD_FUNCTION_EXISTS("crypt", 5)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Crypt must be loaded for password_verify to
function");
+ RETURN_FALSE;
+ }
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &password, &hash) ==
FAILURE) {
RETURN_FALSE;
@@ -195,6 +197,12 @@ PHP_FUNCTION(password_create)
int algo_len = 0, salt_len = 0, required_salt_len = 0, hash_format_len;
HashTable *options = 0;
zval **option_buffer, *ret, *password, *hash_zval;
+ zend_function *func_ptr;
+
+ if (!PHP_PASSWORD_FUNCTION_EXISTS("crypt", 5)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Crypt must be loaded for password_verify to
function");
+ RETURN_FALSE;
+ }
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|sH", &password,
&algo, &algo_len, &options) == FAILURE) {
RETURN_FALSE;