Skip to content

Commit 266f85f

Browse files
authored
replace ERR_NUM_ERRORS with PHP_OPENSSL_ERR_BUFFER_SIZE (#21579)
1 parent 818bc8a commit 266f85f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ext/openssl/openssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ void php_openssl_store_errors(void)
218218
errors = OPENSSL_G(errors);
219219

220220
do {
221-
errors->top = (errors->top + 1) % ERR_NUM_ERRORS;
221+
errors->top = (errors->top + 1) % PHP_OPENSSL_ERR_BUFFER_SIZE;
222222
if (errors->top == errors->bottom) {
223-
errors->bottom = (errors->bottom + 1) % ERR_NUM_ERRORS;
223+
errors->bottom = (errors->bottom + 1) % PHP_OPENSSL_ERR_BUFFER_SIZE;
224224
}
225225
errors->buffer[errors->top] = error_code;
226226
} while ((error_code = ERR_get_error()));
@@ -4042,7 +4042,7 @@ PHP_FUNCTION(openssl_error_string)
40424042
RETURN_FALSE;
40434043
}
40444044

4045-
OPENSSL_G(errors)->bottom = (OPENSSL_G(errors)->bottom + 1) % ERR_NUM_ERRORS;
4045+
OPENSSL_G(errors)->bottom = (OPENSSL_G(errors)->bottom + 1) % PHP_OPENSSL_ERR_BUFFER_SIZE;
40464046
val = OPENSSL_G(errors)->buffer[OPENSSL_G(errors)->bottom];
40474047

40484048
if (val) {

ext/openssl/php_openssl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ extern zend_module_entry openssl_module_entry;
3636
#define PHP_OPENSSL_API_VERSION 0x30200
3737
#endif
3838

39+
#define PHP_OPENSSL_ERR_BUFFER_SIZE 16
40+
3941
#define OPENSSL_RAW_DATA 1
4042
#define OPENSSL_ZERO_PADDING 2
4143
#define OPENSSL_DONT_ZERO_PAD_KEY 4
@@ -65,7 +67,7 @@ extern zend_module_entry openssl_module_entry;
6567
#endif
6668

6769
struct php_openssl_errors {
68-
int buffer[ERR_NUM_ERRORS];
70+
int buffer[PHP_OPENSSL_ERR_BUFFER_SIZE];
6971
int top;
7072
int bottom;
7173
};

0 commit comments

Comments
 (0)