diff options
author | Xinchen Hui <laruence@gmail.com> | 2014-02-24 18:48:22 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2014-02-24 18:48:22 +0800 |
commit | 93428dc6b902f23e56bf01e87c63ea0d6d6c03a4 (patch) | |
tree | b90898523b92e51deab4cf0339d09fe2c65c264a /ext/standard/password.c | |
parent | 1e5a4f281d21abab8101301ea155f9c0394ab02f (diff) | |
download | php-git-93428dc6b902f23e56bf01e87c63ea0d6d6c03a4.tar.gz |
Refactor base64 to returning zend_string
Diffstat (limited to 'ext/standard/password.c')
-rw-r--r-- | ext/standard/password.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/standard/password.c b/ext/standard/password.c index a76bf847d3..f5b925f530 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -82,28 +82,27 @@ static int php_password_salt_is_alphabet(const char *str, const size_t len) /* { static int php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */ { size_t pos = 0; - size_t ret_len = 0; - unsigned char *buffer; + zend_string *buffer; if ((int) str_len < 0) { return FAILURE; } - buffer = php_base64_encode((unsigned char*) str, (int) str_len, (int*) &ret_len); - if (ret_len < out_len) { + buffer = php_base64_encode((unsigned char*) str, (int) str_len); + if (buffer->len < out_len) { /* Too short of an encoded string generated */ - efree(buffer); + STR_RELEASE(buffer); return FAILURE; } for (pos = 0; pos < out_len; pos++) { - if (buffer[pos] == '+') { + if (buffer->val[pos] == '+') { ret[pos] = '.'; - } else if (buffer[pos] == '=') { - efree(buffer); + } else if (buffer->val[pos] == '=') { + STR_FREE(buffer); return FAILURE; } else { - ret[pos] = buffer[pos]; + ret[pos] = buffer->val[pos]; } } - efree(buffer); + STR_FREE(buffer); return SUCCESS; } /* }}} */ |