Commit 4716955b authored by relyea%netscape.com's avatar relyea%netscape.com
Browse files

Fix several memory leaks.
Adjust the default hash sizes down for mozilla client.
Merge the NSS 3.3 key check and signature check stuff.
parent 4bf178bd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,11 @@
#IMPORT_LIBRARY =
#PROGRAM        =


ifdef MOZILLA_CLIENT
DEFINES += -DMOZ_CLIENT
endif

# can't do this in manifest.mn because OS_ARCH isn't defined there.
ifeq ($(OS_ARCH), WINNT)

+10 −16
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
 * may use your version of this file under either the MPL or the
 * GPL.
 *
 # $Id: dbinit.c,v 1.6 2001/11/15 23:04:39 relyea%netscape.com Exp $
 # $Id: dbinit.c,v 1.7 2001/11/30 23:24:29 relyea%netscape.com Exp $
 */

#include <ctype.h>
@@ -209,24 +209,18 @@ loser:
}


#ifdef notdef
void
pk11_Shutdown(void)
pk11_DBShutdown(NSSLOWCERTCertDBHandle *certHandle, 
		NSSLOWKEYDBHandle *keyHandle)
{
    NSSLOWCERTCertDBHandle *certHandle;
    NSSLOWKEYDBHandle *keyHandle;

    PR_FREEIF(secmodname);
    certHandle = nsslowcert_GetDefaultCertDB();
    if (certHandle)
    if (certHandle) {
    	nsslowcert_ClosePermCertDB(certHandle);
    nsslowcert_SetDefaultCertDB(NULL); 
	PORT_Free(certHandle);
	certHandle= NULL;
    }

    keyHandle = nsslowkey_GetDefaultKeyDB();
    if (keyHandle)
    if (keyHandle) {
    	nsslowkey_CloseKeyDB(keyHandle);
    nsslowkey_SetDefaultKeyDB(NULL); 

    isInitialized = PR_FALSE;
	keyHandle= NULL;
    }
}
#endif
+5 −23
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
 *
 * Private Key Database code
 *
 * $Id: keydb.c,v 1.10 2001/11/15 23:04:39 relyea%netscape.com Exp $
 * $Id: keydb.c,v 1.11 2001/11/30 23:24:29 relyea%netscape.com Exp $
 */

#include "lowkeyi.h"
@@ -1093,13 +1093,14 @@ void
nsslowkey_CloseKeyDB(NSSLOWKEYDBHandle *handle)
{
    if (handle != NULL) {
	if (handle == nsslowkey_GetDefaultKeyDB()) {
	    nsslowkey_SetDefaultKeyDB(NULL);
	}
	if (handle->db != NULL) {
	    (* handle->db->close)(handle->db);
	}
	if (handle->dbname) PORT_Free(handle->dbname);
	if (handle->global_salt) {
	    SECITEM_FreeItem(handle->global_salt,PR_TRUE);
	}
	    
	PORT_Free(handle);
    }
}
@@ -1113,25 +1114,6 @@ nsslowkey_GetKeyDBVersion(NSSLOWKEYDBHandle *handle)
    return handle->version;
}

/*
 * Allow use of default key database, so that apps (such as mozilla) do
 * not have to pass the handle all over the place.
 */

static NSSLOWKEYDBHandle *sec_default_key_db = NULL;

void
nsslowkey_SetDefaultKeyDB(NSSLOWKEYDBHandle *handle)
{
    sec_default_key_db = handle;
}

NSSLOWKEYDBHandle *
nsslowkey_GetDefaultKeyDB(void)
{
    return sec_default_key_db;
}

/*
 * Delete a private key that was stored in the database
 */
+1 −56
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
/*
 * Certificate handling code
 *
 * $Id: lowcert.c,v 1.2 2001/11/08 00:15:34 relyea%netscape.com Exp $
 * $Id: lowcert.c,v 1.3 2001/11/30 23:24:30 relyea%netscape.com Exp $
 */

#include "seccomon.h"
@@ -118,44 +118,6 @@ const SEC_ASN1Template nsslowcert_DHPublicKeyTemplate[] = {
};


static PZLock *pcertRefCountLock = NULL;

/*
 * Acquire the cert reference count lock
 * There is currently one global lock for all certs, but I'm putting a cert
 * arg here so that it will be easy to make it per-cert in the future if
 * that turns out to be necessary.
 */
void
nsslowcert_LockCertRefCount(NSSLOWCERTCertificate *cert)
{
    if ( pcertRefCountLock == NULL ) {
	nss_InitLock(&pcertRefCountLock, nssILockRefLock);
	PORT_Assert(pcertRefCountLock != NULL);
    }
    
    PZ_Lock(pcertRefCountLock);
    return;
}

/*
 * Free the cert reference count lock
 */
void
nsslowcert_UnlockCertRefCount(NSSLOWCERTCertificate *cert)
{
    PRStatus prstat;

    PORT_Assert(pcertRefCountLock != NULL);
    
    prstat = PZ_Unlock(pcertRefCountLock);
    
    PORT_Assert(prstat == PR_SUCCESS);

    return;
}


NSSLOWCERTCertificate *
nsslowcert_DupCertificate(NSSLOWCERTCertificate *c)
{
@@ -319,23 +281,6 @@ nsslowcert_DecodeDERCertificate(SECItem *derSignedCert, PRBool copyDER,
    cert->dbEntry = NULL;
    cert ->trust = NULL;

#ifdef notdef
    /* these fields are used by client GUI code to keep track of ssl sockets
     * that are blocked waiting on GUI feedback related to this cert.
     * XXX - these should be moved into some sort of application specific
     *       data structure.  They are only used by the browser right now.
     */
    struct SECSocketNode *socketlist;
    int socketcount;
    struct SECSocketNode *authsocketlist;
    int authsocketcount;

    /* This is PKCS #11 stuff. */
    PK11SlotInfo *slot;		/*if this cert came of a token, which is it*/
    CK_OBJECT_HANDLE pkcs11ID;	/*and which object on that token is it */
    PRBool ownSlot;		/*true if the cert owns the slot reference */
#endif

    /* generate and save the database key for the cert */
    rv = nsslowcert_KeyFromDERCert(arena, &cert->derCert, &cert->certKey);
    if ( rv ) {
+26 −11
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
/*
 * Permanent Certificate database handling code 
 *
 * $Id: pcertdb.c,v 1.3 2001/11/15 23:04:40 relyea%netscape.com Exp $
 * $Id: pcertdb.c,v 1.4 2001/11/30 23:24:30 relyea%netscape.com Exp $
 */
#include "prtime.h"

@@ -117,7 +117,7 @@ static PZLock *certRefCountLock = NULL;
 * arg here so that it will be easy to make it per-cert in the future if
 * that turns out to be necessary.
 */
static void
void
nsslowcert_LockCertRefCount(NSSLOWCERTCertificate *cert)
{
    if ( certRefCountLock == NULL ) {
@@ -132,7 +132,7 @@ nsslowcert_LockCertRefCount(NSSLOWCERTCertificate *cert)
/*
 * Free the cert reference count lock
 */
static void
void
nsslowcert_UnlockCertRefCount(NSSLOWCERTCertificate *cert)
{
    PRStatus prstat;
@@ -3898,21 +3898,19 @@ nsslowcert_TraversePermCerts(NSSLOWCERTCertDBHandle *handle,
 * Close the database
 */
void
__nsslowcert_ClosePermCertDB(NSSLOWCERTCertDBHandle *handle)
nsslowcert_ClosePermCertDB(NSSLOWCERTCertDBHandle *handle)
{
    if ( handle ) {
	if ( handle->permCertDB ) {
	    certdb_Close( handle->permCertDB );
	    handle->permCertDB = 0;
	    handle->permCertDB = NULL;
	}
	if (handle->dbMon) {
    	    PZ_DestroyMonitor(handle->dbMon);
	    handle->dbMon = NULL;
	}
    return;
    }

void
nsslowcert_ClosePermCertDB(NSSLOWCERTCertDBHandle *handle)
{
    __nsslowcert_ClosePermCertDB(handle);
    return;
}

/*
@@ -4455,3 +4453,20 @@ loser:
    }
    return(rv);
}

void
nsslowcert_DestroyGlobalLocks()
{
    if (dbLock) {
	PZ_DestroyLock(dbLock);
	dbLock = NULL;
    }
    if (certRefCountLock) {
	PZ_DestroyLock(certRefCountLock);
	certRefCountLock = NULL;
    }
    if (certTrustLock) {
	PZ_DestroyLock(certTrustLock);
	certTrustLock = NULL;
    }
}
Loading