cvs: php-src(PHP_5_2) /ext/openssl openssl.c /ext/openssl/tests bug36732.phpt
| From: | Pierre-Alain Joye | Date: | Mon, 31 Jul 2006 00:33:41 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/openssl openssl.c /ext/openssl/tests bug36732.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-39662@lists.php.net to get a copy of this message | ||
pajoye Mon Jul 31 00:33:41 2006 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/openssl/tests bug36732.phpt
Modified files:
/php-src/ext/openssl openssl.c
Log:
- #36732, add req_extensions support to openssl_csr_new and _sign
(ben at psc dot edu)
- fix leaks in openssl_csr_new and sign
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.98.2.5.2.7&r2=1.98.2.5.2.8&diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.98.2.5.2.7 php-src/ext/openssl/openssl.c:1.98.2.5.2.8
--- php-src/ext/openssl/openssl.c:1.98.2.5.2.7 Sun Jul 30 17:03:12 2006
+++ php-src/ext/openssl/openssl.c Mon Jul 31 00:33:41 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.98.2.5.2.7 2006/07/30 17:03:12 pajoye Exp $ */
+/* $Id: openssl.c,v 1.98.2.5.2.8 2006/07/31 00:33:41 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -468,8 +468,8 @@
CONF_get_string(req->req_config, req->section_name, "default_md"));
SET_OPTIONAL_STRING_ARG("x509_extensions", req->extensions_section,
CONF_get_string(req->req_config, req->section_name, "x509_extensions"));
- SET_OPTIONAL_STRING_ARG("req_extensions", req->extensions_section,
- CONF_get_string(req->req_config, req->request_extensions_section,
"req_extensions"));
+ SET_OPTIONAL_STRING_ARG("req_extensions", req->request_extensions_section,
+ CONF_get_string(req->req_config, req->section_name, "req_extensions"));
SET_OPTIONAL_LONG_ARG("private_key_bits", req->priv_key_bits,
CONF_get_number(req->req_config, req->section_name, "default_bits"));
@@ -509,9 +509,6 @@
return FAILURE;
}
- if (req->request_extensions_section == NULL) {
- req->request_extensions_section = CONF_get_string(req->req_config, req->section_name,
"req_extensions");
- }
PHP_SSL_CONFIG_SYNTAX_CHECK(request_extensions_section);
return SUCCESS;
@@ -879,8 +876,6 @@
zend_bool notext = 1;
BIO * bio_out;
long certresource;
- char * bio_mem_ptr;
- long bio_mem_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|b", &zcert, &zout,
¬ext) == FAILURE) {
return;
@@ -897,12 +892,15 @@
if (!notext) {
X509_print(bio_out, cert);
}
- PEM_write_bio_X509(bio_out, cert);
+ if (PEM_write_bio_X509(bio_out, cert)) {
+ BUF_MEM *bio_buf;
- bio_mem_len = BIO_get_mem_data(bio_out, &bio_mem_ptr);
- ZVAL_STRINGL(zout, bio_mem_ptr, bio_mem_len, 1);
+ zval_dtor(zout);
+ BIO_get_mem_ptr(bio_out, &bio_buf);
+ ZVAL_STRINGL(zout, bio_buf->data, bio_buf->length, 1);
- RETVAL_TRUE;
+ RETVAL_TRUE;
+ }
if (certresource == -1 && cert) {
X509_free(cert);
@@ -1531,9 +1529,8 @@
zval * zcsr = NULL, *zout=NULL;
zend_bool notext = 1;
BIO * bio_out;
+
long csr_resource;
- char * bio_mem_ptr;
- long bio_mem_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|b", &zcsr, &zout,
¬ext) == FAILURE) {
return;
@@ -1552,12 +1549,16 @@
if (!notext) {
X509_REQ_print(bio_out, csr);
}
- PEM_write_bio_X509_REQ(bio_out, csr);
- bio_mem_len = BIO_get_mem_data(bio_out, &bio_mem_ptr);
- ZVAL_STRINGL(zout, bio_mem_ptr, bio_mem_len, 1);
+ if (PEM_write_bio_X509_REQ(bio_out, csr)) {
+ BUF_MEM *bio_buf;
- RETVAL_TRUE;
+ BIO_get_mem_ptr(bio_out, &bio_buf);
+ zval_dtor(zout);
+ ZVAL_STRINGL(zout, bio_buf->data, bio_buf->length, 1);
+
+ RETVAL_TRUE;
+ }
if (csr_resource == -1 && csr) {
X509_REQ_free(csr);
@@ -1655,12 +1656,12 @@
if (!i) {
goto cleanup;
}
- if (req.request_extensions_section) {
+ if (req.extensions_section) {
X509V3_CTX ctx;
X509V3_set_ctx(&ctx, cert, new_cert, csr, NULL, 0);
X509V3_set_conf_lhash(&ctx, req.req_config);
- if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.request_extensions_section, new_cert)) {
+ if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) {
goto cleanup;
}
}
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/tests/bug36732.phpt?view=markup&rev=1.1
Index: php-src/ext/openssl/tests/bug36732.phpt
+++ php-src/ext/openssl/tests/bug36732.phpt