Commit:    41d7374ea4598000fd626c0d8cd4736aec6357bf
Author:    Anthony Ferrara <ircmax...@gmail.com>         Mon, 25 Jun 2012 
11:37:48 -0400
Parents:   618f2629567ca3a3d1817ca9c4c62339fb5fb886
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=41d7374ea4598000fd626c0d8cd4736aec6357bf

Log:
Implement openssl support for make_salt

Changed paths:
  M  ext/standard/password.c


Diff:
diff --git a/ext/standard/password.c b/ext/standard/password.c
index 013dab7..f2c94fb 100644
--- a/ext/standard/password.c
+++ b/ext/standard/password.c
@@ -96,11 +96,24 @@ static int php_password_make_salt(int length, int raw, char 
*ret TSRMLS_DC)
                zval_ptr_dtor(&size);
                zval_ptr_dtor(&source);
                if (Z_TYPE_P(ret) == IS_STRING) {
-                       memcpy(buffer, Z_STRVAL_P(ret), Z_STRLEN_P(ret));
+                       memcpy(buffer, Z_STRVAL_P(ret), raw_length);
                        buffer_valid = 1;
                }
                zval_ptr_dtor(&ret);
        }
+       if (!buffer_valid && 
PHP_PASSWORD_FUNCTION_EXISTS("openssl_random_pseudo_bytes", 27)) {
+               zval *ret, *size;
+               ALLOC_INIT_ZVAL(size);
+               ZVAL_LONG(size, raw_length);
+               zend_call_method_with_1_params(NULL, NULL, NULL, 
"openssl_random_pseudo_bytes", &ret, size);
+               zval_ptr_dtor(&size);
+               if (Z_TYPE_P(ret) == IS_STRING) {
+                       memcpy(buffer, Z_STRVAL_P(ret), raw_length);
+                       buffer_valid = 1;
+               }
+               zval_ptr_dtor(&ret);
+       }
+
        if (!buffer_valid) {
                long number;
                for (i = 0; i < raw_length; i++) {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to