blob: e41c35a231dc981a82cda6bf1f543c26b26365f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#1, #2:
libressl doesn't yet have sk_new_reserve.
#3:
This check doesn't make sense for EC keys. (Also it ignores the default
key size compiled into libcrypto, only looks at default_bits in openssl.cnf
and any settings in the php file, which results in bogus failures).
Index: ext/openssl/openssl.c
--- ext/openssl/openssl.c.orig
+++ ext/openssl/openssl.c
@@ -2308,7 +2308,7 @@ static STACK_OF(X509) *php_openssl_load_all_certs_from
goto end;
}
- if(!(stack = sk_X509_new_reserve(NULL, sk_X509_INFO_num(sk)))) {
+ if(!(stack = sk_X509_new_null())) {
php_openssl_store_errors();
goto end;
}
@@ -2317,7 +2317,11 @@ static STACK_OF(X509) *php_openssl_load_all_certs_from
while (sk_X509_INFO_num(sk)) {
xi=sk_X509_INFO_shift(sk);
if (xi->x509 != NULL) {
- sk_X509_push(stack,xi->x509);
+ if(sk_X509_push(stack,xi->x509) == 0) {
+ php_error_docref(NULL, E_ERROR, "Memory allocation failure");
+ sk_X509_pop_free(stack,X509_free);
+ goto end;
+ }
xi->x509=NULL;
}
X509_INFO_free(xi);
|