mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
Rewrite openssl_error_string to use stored errors
This commit is contained in:
parent
ceddf003a7
commit
c26b87b8ac
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user