cvs: php4(PHP_4_2_0) /ext/openssl openssl.c
| From: | Wez Furlong | Date: | Wed, 01 May 2002 07:53:52 +0000 |
| Subject: | cvs: php4(PHP_4_2_0) /ext/openssl openssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-11584@lists.php.net to get a copy of this message | ||
wez Wed May 1 03:53:52 2002 EDT
Modified files: (Branch: PHP_4_2_0)
/php4/ext/openssl openssl.c
Log:
MFH fix for #16940, compiler warnings and TSRMLS build fixes.
Index: php4/ext/openssl/openssl.c
diff -u php4/ext/openssl/openssl.c:1.41.2.2 php4/ext/openssl/openssl.c:1.41.2.3
--- php4/ext/openssl/openssl.c:1.41.2.2 Tue Mar 26 03:47:39 2002
+++ php4/ext/openssl/openssl.c Wed May 1 03:53:52 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.41.2.2 2002/03/26 08:47:39 derick Exp $ */
+/* $Id: openssl.c,v 1.41.2.3 2002/05/01 07:53:52 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -140,6 +140,8 @@
static void php_pkey_free(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
EVP_PKEY *pkey = (EVP_PKEY *)rsrc->ptr;
+
+ assert(pkey != NULL);
EVP_PKEY_free(pkey);
}
@@ -188,7 +190,7 @@
static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req TSRMLS_DC);
-static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int shortname)
+static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int shortname TSRMLS_DC)
{
zval * subitem;
int i;
@@ -816,8 +818,15 @@
add_assoc_string(return_value, "name", cert->name, 1);
/* add_assoc_bool(return_value, "valid", cert->valid); */
- add_assoc_name_entry(return_value, "subject", X509_get_subject_name(cert),
useshortnames);
- add_assoc_name_entry(return_value, "issuer", X509_get_issuer_name(cert),
useshortnames);
+ add_assoc_name_entry(return_value, "subject", X509_get_subject_name(cert),
useshortnames TSRMLS_CC);
+ /* hash as used in CA directories to lookup cert by subject name */
+ {
+ char buf[32];
+ snprintf(buf, sizeof(buf), "%08lx", X509_subject_name_hash(cert));
+ add_assoc_string(return_value, "hash", buf, 1);
+ }
+
+ add_assoc_name_entry(return_value, "issuer", X509_get_issuer_name(cert), useshortnames
TSRMLS_CC);
add_assoc_long(return_value, "version", X509_get_version(cert));
add_assoc_long(return_value, "serialNumber",
ASN1_INTEGER_get(X509_get_serialNumber(cert)));
@@ -1098,7 +1107,7 @@
/* {{{ x509 CSR functions */
/* {{{ php_openssl_make_REQ */
-static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, zval * dn, zval *
attribs)
+static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, zval * dn, zval *
attribs TSRMLS_DC)
{
STACK_OF(CONF_VALUE) * dn_sk, *attr_sk = NULL;
char * str, *dn_sect, *attr_sect;
@@ -1251,7 +1260,7 @@
static X509_REQ * php_openssl_csr_from_zval(zval ** val, int makeresource, long * resourceval
TSRMLS_DC)
{
X509_REQ * csr = NULL;
- char * filename;
+ char * filename = NULL;
BIO * in;
if (resourceval)
@@ -1377,7 +1386,7 @@
long num_days;
X509 * cert = NULL, *new_cert = NULL;
X509_REQ * csr;
- EVP_PKEY * key, *priv_key;
+ EVP_PKEY * key = NULL, *priv_key;
long csr_resource, certresource, keyresource;
int i;
struct php_x509_request req;
@@ -1530,7 +1539,7 @@
else {
csr = X509_REQ_new();
if (csr) {
- if (php_openssl_make_REQ(&req, csr, dn, attribs) == SUCCESS) {
+ if (php_openssl_make_REQ(&req, csr, dn, attribs TSRMLS_CC) == SUCCESS) {
X509V3_CTX ext_ctx;
X509V3_set_ctx(&ext_ctx, NULL, NULL, csr, NULL, 0);
@@ -1929,7 +1938,7 @@
Verifys that the data block is intact, the signer is who they say they are, and returns the
CERTs of the signers */
PHP_FUNCTION(openssl_pkcs7_verify)
{
- X509_STORE * store;
+ X509_STORE * store = NULL;
zval * cainfo = NULL;
STACK_OF(X509) *signers= NULL;
STACK_OF(X509) *others = NULL;
@@ -2358,7 +2367,7 @@
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
- unsigned char *cryptedbuf;
+ unsigned char *cryptedbuf = NULL;
unsigned char *crypttemp;
int successful = 0;
long padding = RSA_PKCS1_PADDING;
@@ -2395,7 +2404,8 @@
}
break;
default:
- zend_error(E_WARNING, "%s(): key type not supported in this PHP build!");
+ zend_error(E_WARNING, "%s(): key type not supported in this PHP build!",
+ get_active_function_name(TSRMLS_C));
}
efree(crypttemp);
@@ -2453,7 +2463,8 @@
padding) == cryptedlen);
break;
default:
- zend_error(E_WARNING, "%s(): key type not supported in this PHP build!");
+ zend_error(E_WARNING, "%s(): key type not supported in this PHP build!",
+ get_active_function_name(TSRMLS_C));
}
@@ -2478,7 +2489,7 @@
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
- unsigned char *cryptedbuf;
+ unsigned char *cryptedbuf = NULL;
unsigned char *crypttemp;
int successful = 0;
long keyresource = -1;
@@ -2516,7 +2527,8 @@
break;
default:
- zend_error(E_WARNING, "%s(): key type not supported in this PHP build!");
+ zend_error(E_WARNING, "%s(): key type not supported in this PHP build!",
+ get_active_function_name(TSRMLS_C));
}