summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2016-02-02 16:26:03 +0000
committerJakub Zelenka <bukka@php.net>2016-02-02 16:26:03 +0000
commitc26b87b8ac0548a6cdbb75d3395c8f000836dd69 (patch)
treef44ed621710a85710817756a9cc6918d5728baba
parentceddf003a716a2d2f6a518cff4de5bb59e5cff54 (diff)
downloadphp-git-c26b87b8ac0548a6cdbb75d3395c8f000836dd69.tar.gz
Rewrite openssl_error_string to use stored errors
-rw-r--r--ext/openssl/openssl.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 0a83fa574f..9615d61311 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -5047,16 +5047,25 @@ PHP_FUNCTION(openssl_public_decrypt)
Returns a description of the last error, and alters the index of the error messages. Returns false when the are no more messages */
PHP_FUNCTION(openssl_error_string)
{
- char buf[512];
+ char buf[256];
unsigned long val;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- val = ERR_get_error();
+ php_openssl_store_errors();
+
+ if (OPENSSL_G(errors) == NULL || OPENSSL_G(errors)->top == OPENSSL_G(errors)->bottom) {
+ RETURN_FALSE;
+ }
+
+ OPENSSL_G(errors)->bottom = (OPENSSL_G(errors)->bottom + 1) % ERR_NUM_ERRORS;
+ val = OPENSSL_G(errors)->buffer[OPENSSL_G(errors)->bottom];
+
if (val) {
- RETURN_STRING(ERR_error_string(val, buf));
+ ERR_error_string_n(val, buf, 256);
+ RETURN_STRING(buf);
} else {
RETURN_FALSE;
}