From: Jakub Zelenka Date: Sun, 15 Oct 2017 19:31:25 +0000 (+0100) Subject: Merge branch 'PHP-7.0' into PHP-7.1 X-Git-Tag: php-7.2.0RC5~49^2~2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=547fee9cd44d3aed19490971e2d06f275a7b522b;p=php Merge branch 'PHP-7.0' into PHP-7.1 --- 547fee9cd44d3aed19490971e2d06f275a7b522b diff --cc ext/openssl/openssl.c index b199e0a68c,9b8a2fc968..b5b0e87b54 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@@ -1758,16 -1672,13 +1757,16 @@@ PHP_FUNCTION(openssl_x509_export_to_fil RETVAL_TRUE; } else { + php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "error opening file %s", filename); } - if (certresource == NULL && cert) { + if (Z_TYPE_P(zcert) != IS_RESOURCE) { X509_free(cert); } - BIO_free(bio_out); + + if (!BIO_free(bio_out)) { + php_openssl_store_errors(); + } } /* }}} */ @@@ -2099,16 -1991,12 +2097,16 @@@ PHP_FUNCTION(openssl_x509_export ZVAL_STRINGL(zout, bio_buf->data, bio_buf->length); RETVAL_TRUE; + } else { + php_openssl_store_errors(); } + BIO_free(bio_out); + +cleanup: - if (certresource == NULL && cert != NULL) { + if (Z_TYPE_P(zcert) != IS_RESOURCE) { X509_free(cert); } - BIO_free(bio_out); } /* }}} */ @@@ -2775,8 -2642,7 +2776,8 @@@ PHP_FUNCTION(openssl_pkcs12_export_to_f php_error_docref(NULL, E_WARNING, "cannot get private key from parameter 3"); goto cleanup; } - if (cert && !X509_check_private_key(cert, priv_key)) { + if (!X509_check_private_key(cert, priv_key)) { + php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "private key does not correspond to cert"); goto cleanup; }