r3566 - in trunk/libmcrypto: include/libmcrypto include/libmcrypto/gnutls include/libmcrypto/openssl source/gnutls source/openssl

erik at minisip.org erik at minisip.org
Wed Mar 12 00:21:55 CET 2008


Author: erik
Date: 2008-03-12 00:21:54 +0100 (Wed, 12 Mar 2008)
New Revision: 3566

Modified:
   trunk/libmcrypto/include/libmcrypto/cert.h
   trunk/libmcrypto/include/libmcrypto/gnutls/cert.h
   trunk/libmcrypto/include/libmcrypto/openssl/cert.h
   trunk/libmcrypto/source/gnutls/cert.cxx
   trunk/libmcrypto/source/openssl/cert.cxx
Log:

 * Fixed problem with Certificate::load(cert,privkey)

   Certificate* Certificate::load(string certfile, string privkeyfile) did not work
   correctly. When the object was created, it called setPk that took an
   MRef to a certificate. This caused the memory to be freed, and a bad
   memory location was returned.



Modified: trunk/libmcrypto/include/libmcrypto/cert.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/cert.h	2008-01-10 19:39:58 UTC (rev 3565)
+++ trunk/libmcrypto/include/libmcrypto/cert.h	2008-03-11 23:21:54 UTC (rev 3566)
@@ -240,7 +240,13 @@
 
 		virtual const std::string &getFile() const = 0;
 
-		virtual bool checkCert( MRef<Certificate *> cert)=0;
+		//Note that the parameter is not a MRef because of
+		//implementation issues. We want to allow
+		//Certificate::setPk to be used on objects not using
+		//MRefs. (If this parameter used MRefs, then the
+		//cert is garbage collected if there is no other
+		//reference to it)
+		virtual bool checkCert( Certificate * cert)=0;
 
 		virtual int signData( unsigned char * data, int data_length,
 				       unsigned char * sign,

Modified: trunk/libmcrypto/include/libmcrypto/gnutls/cert.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/gnutls/cert.h	2008-01-10 19:39:58 UTC (rev 3565)
+++ trunk/libmcrypto/include/libmcrypto/gnutls/cert.h	2008-03-11 23:21:54 UTC (rev 3566)
@@ -103,7 +103,7 @@
 
 		const std::string &getFile() const;
 
-		bool checkCert( MRef<Certificate*> cert );
+		bool checkCert( Certificate* cert );
 
 		int signData( unsigned char * data, int data_length,
 			       unsigned char * sign,

Modified: trunk/libmcrypto/include/libmcrypto/openssl/cert.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/openssl/cert.h	2008-01-10 19:39:58 UTC (rev 3565)
+++ trunk/libmcrypto/include/libmcrypto/openssl/cert.h	2008-03-11 23:21:54 UTC (rev 3566)
@@ -76,7 +76,7 @@
 
 		const std::string &getFile() const;
 
-		bool checkCert( MRef<Certificate *> cert);
+		bool checkCert( Certificate * cert);
 
 		int signData( unsigned char * data, int data_length,
 			       unsigned char * sign,

Modified: trunk/libmcrypto/source/gnutls/cert.cxx
===================================================================
--- trunk/libmcrypto/source/gnutls/cert.cxx	2008-01-10 19:39:58 UTC (rev 3565)
+++ trunk/libmcrypto/source/gnutls/cert.cxx	2008-03-11 23:21:54 UTC (rev 3566)
@@ -1006,9 +1006,9 @@
 }
 
 
-bool GtlsPrivateKey::checkCert( MRef<Certificate*> cert ){
-	MRef<GtlsCertificate*> Gtlscert =
-		dynamic_cast<GtlsCertificate*>( *cert );
+bool GtlsPrivateKey::checkCert( Certificate* cert ){
+	GtlsCertificate* Gtlscert =
+		dynamic_cast<GtlsCertificate*>( cert );
 
 	if( !Gtlscert ){
 		return false;

Modified: trunk/libmcrypto/source/openssl/cert.cxx
===================================================================
--- trunk/libmcrypto/source/openssl/cert.cxx	2008-01-10 19:39:58 UTC (rev 3565)
+++ trunk/libmcrypto/source/openssl/cert.cxx	2008-03-11 23:21:54 UTC (rev 3566)
@@ -83,10 +83,14 @@
 
 Certificate* Certificate::load( const std::string cert_filename,
 				const std::string private_key_filename ){
+	cerr <<"EEEE: osslcert::load 1"<<endl;
 	MRef<PrivateKey*> PrivateKey = new OsslPrivateKey( private_key_filename );
+	cerr <<"EEEE: osslcert::load 2"<<endl;
 	Certificate* cert = new OsslCertificate( cert_filename );
 
+	cerr <<"EEEE: osslcert::load 3"<<endl;
 	cert->setPk( PrivateKey );
+	cerr <<"EEEE: osslcert::load 4"<<endl;
 	return cert;
 }
 
@@ -135,7 +139,7 @@
 	cert = Osslcert;
 }
 
-OsslCertificate::OsslCertificate( const string &cert_filename ){
+OsslCertificate::OsslCertificate( const string &cert_filename ) : Certificate(){
 	FILE * fp;
 
 	fp = fopen( cert_filename.c_str(), "r" );
@@ -640,9 +644,9 @@
 }
 
 
-bool OsslPrivateKey::checkCert( MRef<Certificate*> cert ){
-	MRef<OsslCertificate*> ssl_cert =
-		dynamic_cast<OsslCertificate*>( *cert );
+bool OsslPrivateKey::checkCert( Certificate* cert ){
+	OsslCertificate* ssl_cert =
+		dynamic_cast<OsslCertificate*>( cert );
 
 	if( !ssl_cert ){
 		// Not an OpenSSL Certificate!



More information about the Minisip-devel mailing list