mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Merge branch 'PHP-7.3' into PHP-7.4
This commit is contained in:
commit
021bb35aec
2 changed files with 34 additions and 13 deletions
|
@ -2102,6 +2102,9 @@ cleanup:
|
||||||
if (spkstr_cleaned != NULL) {
|
if (spkstr_cleaned != NULL) {
|
||||||
efree(spkstr_cleaned);
|
efree(spkstr_cleaned);
|
||||||
}
|
}
|
||||||
|
if (spki) {
|
||||||
|
NETSCAPE_SPKI_free(spki);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -3097,8 +3100,6 @@ PHP_FUNCTION(openssl_pkcs12_read)
|
||||||
}
|
}
|
||||||
|
|
||||||
RETVAL_TRUE;
|
RETVAL_TRUE;
|
||||||
|
|
||||||
PKCS12_free(p12);
|
|
||||||
} else {
|
} else {
|
||||||
php_openssl_store_errors();
|
php_openssl_store_errors();
|
||||||
}
|
}
|
||||||
|
@ -3113,6 +3114,9 @@ PHP_FUNCTION(openssl_pkcs12_read)
|
||||||
if (cert) {
|
if (cert) {
|
||||||
X509_free(cert);
|
X509_free(cert);
|
||||||
}
|
}
|
||||||
|
if (p12) {
|
||||||
|
PKCS12_free(p12);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -3697,7 +3701,10 @@ PHP_FUNCTION(openssl_csr_get_subject)
|
||||||
|
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
php_openssl_add_assoc_name_entry(return_value, NULL, subject, use_shortnames);
|
php_openssl_add_assoc_name_entry(return_value, NULL, subject, use_shortnames);
|
||||||
return;
|
|
||||||
|
if (!csr_resource) {
|
||||||
|
X509_REQ_free(csr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -3709,16 +3716,16 @@ PHP_FUNCTION(openssl_csr_get_public_key)
|
||||||
zend_bool use_shortnames = 1;
|
zend_bool use_shortnames = 1;
|
||||||
zend_resource *csr_resource;
|
zend_resource *csr_resource;
|
||||||
|
|
||||||
X509_REQ * csr;
|
X509_REQ *orig_csr, *csr;
|
||||||
EVP_PKEY *tpubkey;
|
EVP_PKEY *tpubkey;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &zcsr, &use_shortnames) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &zcsr, &use_shortnames) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
csr = php_openssl_csr_from_zval(zcsr, 0, &csr_resource);
|
orig_csr = php_openssl_csr_from_zval(zcsr, 0, &csr_resource);
|
||||||
|
|
||||||
if (csr == NULL) {
|
if (orig_csr == NULL) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3728,15 +3735,23 @@ PHP_FUNCTION(openssl_csr_get_public_key)
|
||||||
* a private key, it will be returned including the private part.
|
* a private key, it will be returned including the private part.
|
||||||
* If we duplicate it, then we get just the public part which is
|
* If we duplicate it, then we get just the public part which is
|
||||||
* the same behavior as for OpenSSL 1.0 */
|
* the same behavior as for OpenSSL 1.0 */
|
||||||
csr = X509_REQ_dup(csr);
|
csr = X509_REQ_dup(orig_csr);
|
||||||
|
#else
|
||||||
|
csr = orig_csr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Retrieve the public key from the CSR */
|
/* Retrieve the public key from the CSR */
|
||||||
tpubkey = X509_REQ_get_pubkey(csr);
|
tpubkey = X509_REQ_get_pubkey(csr);
|
||||||
|
|
||||||
#if PHP_OPENSSL_API_VERSION >= 0x10100
|
if (csr != orig_csr) {
|
||||||
/* We need to free the CSR as it was duplicated */
|
/* We need to free the duplicated CSR */
|
||||||
X509_REQ_free(csr);
|
X509_REQ_free(csr);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
if (!csr_resource) {
|
||||||
|
/* We also need to free the original CSR if it was freshly created */
|
||||||
|
X509_REQ_free(orig_csr);
|
||||||
|
}
|
||||||
|
|
||||||
if (tpubkey == NULL) {
|
if (tpubkey == NULL) {
|
||||||
php_openssl_store_errors();
|
php_openssl_store_errors();
|
||||||
|
@ -4439,7 +4454,7 @@ PHP_FUNCTION(openssl_pkey_new)
|
||||||
EC_KEY *eckey = NULL;
|
EC_KEY *eckey = NULL;
|
||||||
EC_GROUP *group = NULL;
|
EC_GROUP *group = NULL;
|
||||||
EC_POINT *pnt = NULL;
|
EC_POINT *pnt = NULL;
|
||||||
const BIGNUM *d;
|
BIGNUM *d = NULL;
|
||||||
pkey = EVP_PKEY_new();
|
pkey = EVP_PKEY_new();
|
||||||
if (pkey) {
|
if (pkey) {
|
||||||
eckey = EC_KEY_new();
|
eckey = EC_KEY_new();
|
||||||
|
@ -4487,6 +4502,8 @@ PHP_FUNCTION(openssl_pkey_new)
|
||||||
php_openssl_store_errors();
|
php_openssl_store_errors();
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BN_free(d);
|
||||||
} else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL &&
|
} else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL &&
|
||||||
Z_TYPE_P(x) == IS_STRING &&
|
Z_TYPE_P(x) == IS_STRING &&
|
||||||
(y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL &&
|
(y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL &&
|
||||||
|
@ -4531,6 +4548,9 @@ PHP_FUNCTION(openssl_pkey_new)
|
||||||
php_openssl_store_errors();
|
php_openssl_store_errors();
|
||||||
}
|
}
|
||||||
clean_exit:
|
clean_exit:
|
||||||
|
if (d != NULL) {
|
||||||
|
BN_free(d);
|
||||||
|
}
|
||||||
if (pnt != NULL) {
|
if (pnt != NULL) {
|
||||||
EC_POINT_free(pnt);
|
EC_POINT_free(pnt);
|
||||||
}
|
}
|
||||||
|
@ -5267,7 +5287,7 @@ clean_exit:
|
||||||
BIO_free(in);
|
BIO_free(in);
|
||||||
BIO_free(dataout);
|
BIO_free(dataout);
|
||||||
PKCS7_free(p7);
|
PKCS7_free(p7);
|
||||||
sk_X509_free(others);
|
sk_X509_pop_free(others, X509_free);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -856,6 +856,7 @@ static long php_openssl_load_stream_cafile(X509_STORE *cert_store, const char *c
|
||||||
buffer_active = 0;
|
buffer_active = 0;
|
||||||
if (cert && X509_STORE_add_cert(cert_store, cert)) {
|
if (cert && X509_STORE_add_cert(cert_store, cert)) {
|
||||||
++certs_added;
|
++certs_added;
|
||||||
|
X509_free(cert);
|
||||||
}
|
}
|
||||||
goto cert_start;
|
goto cert_start;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue