diff options
author | Nikita Popov <nikic@php.net> | 2015-04-25 20:43:11 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2015-04-27 18:50:08 +0200 |
commit | 40e465e3575443757693146bb141a4de02cc697c (patch) | |
tree | 6eb7c1fc0ffeb24d3bcf3cc34ecd294c39a2e4e4 /ext/standard/password.c | |
parent | 1800bed1045a43d2478c0265a26fe0675fb5a6c1 (diff) | |
download | php-git-40e465e3575443757693146bb141a4de02cc697c.tar.gz |
Clean up some type conversions
While at it also fix some type checks in iconv and drop dead and
unported code in standard/filters.
Diffstat (limited to 'ext/standard/password.c')
-rw-r--r-- | ext/standard/password.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/ext/standard/password.c b/ext/standard/password.c index 656dc50cbb..209e2533f8 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -231,16 +231,8 @@ PHP_FUNCTION(password_needs_rehash) { zend_long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0; - if (options && (option_buffer = zend_symtable_str_find(options, "cost", sizeof("cost")-1)) != NULL) { - if (Z_TYPE_P(option_buffer) != IS_LONG) { - zval cast_option_buffer; - ZVAL_DUP(&cast_option_buffer, option_buffer); - convert_to_long(&cast_option_buffer); - new_cost = Z_LVAL(cast_option_buffer); - zval_dtor(&cast_option_buffer); - } else { - new_cost = Z_LVAL_P(option_buffer); - } + if (options && (option_buffer = zend_hash_str_find(options, "cost", sizeof("cost")-1)) != NULL) { + new_cost = zval_get_long(option_buffer); } sscanf(hash, "$2y$" ZEND_LONG_FMT "$", &cost); @@ -314,16 +306,8 @@ PHP_FUNCTION(password_hash) { zend_long cost = PHP_PASSWORD_BCRYPT_COST; - if (options && (option_buffer = zend_symtable_str_find(options, "cost", sizeof("cost")-1)) != NULL) { - if (Z_TYPE_P(option_buffer) != IS_LONG) { - zval cast_option_buffer; - ZVAL_DUP(&cast_option_buffer, option_buffer); - convert_to_long(&cast_option_buffer); - cost = Z_LVAL(cast_option_buffer); - zval_dtor(&cast_option_buffer); - } else { - cost = Z_LVAL_P(option_buffer); - } + if (options && (option_buffer = zend_hash_str_find(options, "cost", sizeof("cost")-1)) != NULL) { + cost = zval_get_long(option_buffer); } if (cost < 4 || cost > 31) { @@ -343,7 +327,7 @@ PHP_FUNCTION(password_hash) RETURN_NULL(); } - if (options && (option_buffer = zend_symtable_str_find(options, "salt", sizeof("salt")-1)) != NULL) { + if (options && (option_buffer = zend_hash_str_find(options, "salt", sizeof("salt")-1)) != NULL) { char *buffer; size_t buffer_len = 0; |