Bug 1028588 - Fix dangerous public destructors in security/ - r=bsmith

This commit is contained in:
Benoit Jacob 2014-06-23 18:40:03 -04:00
parent 3cd63fe627
commit c26bd2e511
43 changed files with 122 additions and 34 deletions

View File

@ -18,7 +18,6 @@ class nsEntropyCollector : public nsIBufEntropyCollector
{
public:
nsEntropyCollector();
virtual ~nsEntropyCollector();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIENTROPYCOLLECTOR
@ -27,6 +26,8 @@ class nsEntropyCollector : public nsIBufEntropyCollector
enum { entropy_buffer_size = 1024 };
protected:
virtual ~nsEntropyCollector();
unsigned char mEntropyCache[entropy_buffer_size];
int32_t mBytesCollected;
unsigned char *mWritePointer;

View File

@ -1612,6 +1612,8 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
nsUIContext(nsIDOMWindow *window);
protected:
virtual ~nsUIContext();
private:

View File

@ -47,7 +47,6 @@ class nsSecureBrowserUIImpl : public nsISecureBrowserUI,
public:
nsSecureBrowserUIImpl();
virtual ~nsSecureBrowserUIImpl();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
@ -61,6 +60,8 @@ public:
nsIArray* invalidElements) { return NS_OK; }
protected:
virtual ~nsSecureBrowserUIImpl();
mozilla::ReentrantMonitor mReentrantMonitor;
nsWeakPtr mWindow;

View File

@ -19,11 +19,12 @@ public:
NS_DECL_NSISECURITYWARNINGDIALOGS
nsSecurityWarningDialogs();
virtual ~nsSecurityWarningDialogs();
nsresult Init();
protected:
virtual ~nsSecurityWarningDialogs();
nsresult AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
const char16_t *messageName,
const char16_t *showAgainName,

View File

@ -131,6 +131,8 @@ public:
nsSiteSecurityService();
nsresult Init();
protected:
virtual ~nsSiteSecurityService();
private:

View File

@ -31,8 +31,8 @@ public:
NS_DECL_NSITREEVIEW
nsNSSASN1Tree();
virtual ~nsNSSASN1Tree();
protected:
virtual ~nsNSSASN1Tree();
class myNode
{

View File

@ -14,9 +14,10 @@
class nsFormSigningDialog MOZ_FINAL : public nsIFormSigningDialog
{
private:
~nsFormSigningDialog();
public:
nsFormSigningDialog();
~nsFormSigningDialog();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIFORMSIGNINGDIALOG

View File

@ -41,11 +41,11 @@ public:
NS_DECL_NSIDOMCRYPTODIALOGS
NS_DECL_NSIGENERATINGKEYPAIRINFODIALOGS
nsNSSDialogs();
virtual ~nsNSSDialogs();
nsresult Init();
protected:
virtual ~nsNSSDialogs();
nsCOMPtr<nsIStringBundle> mPIPStringBundle;
};

View File

@ -22,13 +22,13 @@ class nsPKIParamBlock : public nsIPKIParamBlock,
public:
nsPKIParamBlock();
virtual ~nsPKIParamBlock();
nsresult Init();
NS_DECL_NSIPKIPARAMBLOCK
NS_DECL_NSIDIALOGPARAMBLOCK
NS_DECL_THREADSAFE_ISUPPORTS
private:
virtual ~nsPKIParamBlock();
nsCOMPtr<nsIDialogParamBlock> mDialogParamBlock;
nsCOMPtr<nsISupportsArray> mSupports;
};

View File

@ -36,7 +36,6 @@ class PSMContentDownloader : public nsIStreamListener
public:
PSMContentDownloader() {NS_ASSERTION(false, "don't use this constructor."); }
PSMContentDownloader(uint32_t type);
virtual ~PSMContentDownloader();
void setSilentDownload(bool flag);
NS_DECL_ISUPPORTS
@ -50,6 +49,8 @@ public:
enum {X509_SERVER_CERT = 4};
protected:
virtual ~PSMContentDownloader();
char* mByteData;
int32_t mBufferOffset;
int32_t mBufferSize;

View File

@ -20,11 +20,14 @@ class PSMContentListener : public nsIURIContentListener,
public nsSupportsWeakReference {
public:
PSMContentListener();
virtual ~PSMContentListener();
nsresult init();
NS_DECL_ISUPPORTS
NS_DECL_NSIURICONTENTLISTENER
protected:
virtual ~PSMContentListener();
private:
nsCOMPtr<nsISupports> mLoadCookie;
nsCOMPtr<nsIURIContentListener> mParentContentListener;

View File

@ -109,6 +109,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
PrivateBrowsingObserver(SharedSSLState* aOwner) : mOwner(aOwner) {}
protected:
virtual ~PrivateBrowsingObserver() {}
private:
SharedSSLState* mOwner;

View File

@ -34,9 +34,10 @@ class TransportSecurityInfo : public nsITransportSecurityInfo,
public nsNSSShutDownObject,
public nsOnPK11LogoutCancelObject
{
protected:
virtual ~TransportSecurityInfo();
public:
TransportSecurityInfo();
virtual ~TransportSecurityInfo();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITRANSPORTSECURITYINFO

View File

@ -136,7 +136,6 @@ public:
NS_DECL_NSIOBSERVER
nsCertOverrideService();
~nsCertOverrideService();
nsresult Init();
void RemoveAllTemporaryOverrides();
@ -157,6 +156,8 @@ public:
static void GetHostWithPort(const nsACString & aHostName, int32_t aPort, nsACString& _retval);
protected:
~nsCertOverrideService();
mozilla::ReentrantMonitor monitor;
nsCOMPtr<nsIFile> mSettingsFile;
nsTHashtable<nsCertOverrideEntry> mSettingsTable;

View File

@ -18,9 +18,9 @@ public:
NS_DECL_NSIUSERCERTPICKER
nsCertPicker();
protected:
virtual ~nsCertPicker();
private:
};
#endif //_NSCERTPICKER_H_

View File

@ -38,6 +38,9 @@ struct CompareCacheHashEntryPtr : PLDHashEntryHdr {
class nsCertAddonInfo MOZ_FINAL : public nsISupports
{
private:
~nsCertAddonInfo() {}
public:
NS_DECL_ISUPPORTS
@ -51,13 +54,15 @@ public:
class nsCertTreeDispInfo : public nsICertTreeItem
{
protected:
virtual ~nsCertTreeDispInfo();
public:
NS_DECL_ISUPPORTS
NS_DECL_NSICERTTREEITEM
nsCertTreeDispInfo();
nsCertTreeDispInfo(nsCertTreeDispInfo &other);
virtual ~nsCertTreeDispInfo();
mozilla::RefPtr<nsCertAddonInfo> mAddonInfo;
enum {
@ -78,12 +83,13 @@ public:
NS_DECL_NSITREEVIEW
nsCertTree();
virtual ~nsCertTree();
enum sortCriterion { sort_IssuerOrg, sort_Org, sort_Token,
sort_CommonName, sort_IssuedDateDescending, sort_Email, sort_None };
protected:
virtual ~nsCertTree();
nsresult InitCompareHash();
void ClearCompareHash();
void RemoveCacheEntry(void *key);

View File

@ -26,6 +26,7 @@ public:
, mCert(aCert)
{}
protected:
virtual ~nsCertificatePrincipal() {}
private:

View File

@ -114,7 +114,6 @@ public:
NS_DECL_NSIOBSERVER
nsClientAuthRememberService();
~nsClientAuthRememberService();
nsresult Init();
@ -131,6 +130,8 @@ public:
static void ClearAllRememberedDecisions();
protected:
~nsClientAuthRememberService();
mozilla::ReentrantMonitor monitor;
nsTHashtable<nsClientAuthRememberEntry> mSettingsTable;

View File

@ -168,12 +168,13 @@ typedef struct nsKeyPairInfoStr {
class nsCryptoRunArgs : public nsISupports {
public:
nsCryptoRunArgs(JSContext *aCx);
virtual ~nsCryptoRunArgs();
nsCOMPtr<nsISupports> m_kungFuDeathGrip;
JSContext *m_cx;
JS::PersistentRooted<JSObject*> m_scope;
nsXPIDLCString m_jsCallback;
NS_DECL_ISUPPORTS
protected:
virtual ~nsCryptoRunArgs();
};
//This class is used to run the callback code
@ -191,6 +192,13 @@ private:
nsCryptoRunArgs *m_args;
};
namespace mozilla {
template<>
struct HasDangerousPublicDestructor<nsCryptoRunnable>
{
static const bool value = true;
};
}
//We're going to inherit the memory passed
//into us.
@ -199,10 +207,11 @@ private:
class nsP12Runnable : public nsIRunnable {
public:
nsP12Runnable(nsIX509Cert **certArr, int32_t numCerts, nsIPK11Token *token);
virtual ~nsP12Runnable();
NS_IMETHOD Run();
NS_DECL_ISUPPORTS
protected:
virtual ~nsP12Runnable();
private:
nsCOMPtr<nsIPK11Token> mToken;
nsIX509Cert **mCertArr;

View File

@ -104,11 +104,12 @@ class nsPkcs11 : public nsIPKCS11
{
public:
nsPkcs11();
virtual ~nsPkcs11();
NS_DECL_ISUPPORTS
NS_DECL_NSIPKCS11
protected:
virtual ~nsPkcs11();
};
#endif //_nsCrypto_h_

View File

@ -22,7 +22,6 @@ SECKEYECParams *decode_ec_params(const char *curve);
class nsKeygenFormProcessor : public nsIFormProcessor {
public:
nsKeygenFormProcessor();
virtual ~nsKeygenFormProcessor();
nsresult Init();
NS_IMETHOD ProcessValue(nsIDOMHTMLElement *aElement,
@ -37,6 +36,8 @@ public:
static nsresult Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
protected:
virtual ~nsKeygenFormProcessor();
nsresult GetPublicKey(nsAString& aValue, nsAString& aChallenge,
nsAFlatString& akeyType, nsAString& aOutPublicKey,
nsAString& aPqg);

View File

@ -40,10 +40,12 @@ private:
void *wincx;
PRThread *threadHandle;
protected:
virtual ~nsKeygenThread();
public:
nsKeygenThread();
virtual ~nsKeygenThread();
NS_DECL_NSIKEYGENTHREAD
NS_DECL_THREADSAFE_ISUPPORTS

View File

@ -25,6 +25,7 @@ public:
NS_DECL_NSIASN1OBJECT
nsNSSASN1Sequence();
protected:
virtual ~nsNSSASN1Sequence();
/* additional members */
private:
@ -45,6 +46,7 @@ public:
NS_DECL_NSIASN1OBJECT
nsNSSASN1PrintableItem();
protected:
virtual ~nsNSSASN1PrintableItem();
/* additional members */
private:

View File

@ -20,6 +20,8 @@ public:
NS_DECL_NSINSSCERTCACHE
nsNSSCertCache();
protected:
virtual ~nsNSSCertCache();
private:

View File

@ -17,6 +17,8 @@ public:
nsX509CertValidity();
nsX509CertValidity(CERTCertificate *cert);
protected:
virtual ~nsX509CertValidity();
/* additional members */

View File

@ -74,6 +74,14 @@ private:
nsresult getValidEVOidTag(SECOidTag& resultOidTag, bool& validEV);
};
namespace mozilla {
template<>
struct HasDangerousPublicDestructor<nsNSSCertificate>
{
static const bool value = true;
};
}
class nsNSSCertList: public nsIX509CertList,
public nsNSSShutDownObject
{

View File

@ -27,7 +27,6 @@ public:
NS_DECL_NSIX509CERTDB2
nsNSSCertificateDB();
virtual ~nsNSSCertificateDB();
// Use this function to generate a default nickname for a user
// certificate that is to be imported onto a token.
@ -40,6 +39,9 @@ public:
ImportValidCACerts(int numCACerts, SECItem *CACerts, nsIInterfaceRequestor *ctx,
const nsNSSShutDownPreventionLock &proofOfLock);
protected:
virtual ~nsNSSCertificateDB();
private:
static nsresult

View File

@ -23,6 +23,8 @@ public:
NS_DECL_NSICLASSINFO
nsNSSCertificateFakeTransport();
protected:
virtual ~nsNSSCertificateFakeTransport();
private:

View File

@ -88,10 +88,11 @@ extern char* pk11PasswordPrompt(PK11SlotInfo* slot, PRBool retry, void* arg);
class nsTokenEventRunnable : public nsIRunnable {
public:
nsTokenEventRunnable(const nsAString& aType, const nsAString& aTokenName);
virtual ~nsTokenEventRunnable();
NS_IMETHOD Run ();
NS_DECL_THREADSAFE_ISUPPORTS
protected:
virtual ~nsTokenEventRunnable();
private:
nsString mType;
nsString mTokenName;
@ -898,10 +899,12 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
virtual ~CipherSuiteChangeObserver() {}
static nsresult StartObserve();
static nsresult StopObserve();
protected:
virtual ~CipherSuiteChangeObserver() {}
private:
static StaticRefPtr<CipherSuiteChangeObserver> sObserver;
CipherSuiteChangeObserver() {}

View File

@ -125,7 +125,6 @@ public:
NS_DEFINE_STATIC_CID_ACCESSOR( NS_NSSCOMPONENT_CID )
nsNSSComponent();
virtual ~nsNSSComponent();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSISIGNATUREVERIFIER
@ -168,6 +167,9 @@ public:
::mozilla::TemporaryRef<mozilla::psm::SharedCertVerifier>
GetDefaultCertVerifier() MOZ_OVERRIDE;
protected:
virtual ~nsNSSComponent();
private:
nsresult InitializeNSS();
void ShutdownNSS();

View File

@ -22,8 +22,9 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
PipUIContext();
virtual ~PipUIContext();
protected:
virtual ~PipUIContext();
};
//

View File

@ -1377,6 +1377,8 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIOBSERVER
PrefObserver(nsSSLIOLayerHelpers* aOwner) : mOwner(aOwner) {}
protected:
virtual ~PrefObserver() {}
private:
nsSSLIOLayerHelpers* mOwner;

View File

@ -16,11 +16,14 @@ public:
NS_DECL_NSIAUTHMODULE
nsNTLMAuthModule() {}
virtual ~nsNTLMAuthModule();
nsresult InitTest();
static void SetSendLM(bool sendLM);
protected:
virtual ~nsNTLMAuthModule();
private:
nsString mDomain;
nsString mUsername;

View File

@ -24,9 +24,11 @@ public:
NS_DECL_NSIPK11TOKEN
nsPK11Token(PK11SlotInfo *slot);
virtual ~nsPK11Token();
/* additional members */
protected:
virtual ~nsPK11Token();
private:
friend class nsPK11TokenDB;
void refreshTokenInfo();
@ -48,6 +50,8 @@ public:
NS_DECL_NSIPK11TOKENDB
nsPK11TokenDB();
protected:
virtual ~nsPK11TokenDB();
/* additional members */
};

View File

@ -24,6 +24,8 @@ public:
NS_DECL_NSIPKCS11SLOT
nsPKCS11Slot(PK11SlotInfo *slot);
protected:
virtual ~nsPKCS11Slot();
private:
@ -45,6 +47,8 @@ public:
NS_DECL_NSIPKCS11MODULE
nsPKCS11Module(SECMODModule *module);
protected:
virtual ~nsPKCS11Module();
private:
@ -63,6 +67,8 @@ public:
NS_DECL_NSICRYPTOFIPSINFO
nsPKCS11ModuleDB();
protected:
virtual ~nsPKCS11ModuleDB();
/* additional members */
};

View File

@ -35,7 +35,6 @@ private:
public:
nsProtectedAuthThread();
virtual ~nsProtectedAuthThread();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIPROTECTEDAUTHTHREAD
@ -49,6 +48,9 @@ public:
void Join(void);
void Run(void);
protected:
virtual ~nsProtectedAuthThread();
};
#endif // NSPROTECTEDAUTHTHREAD_H_

View File

@ -16,6 +16,8 @@
class nsRandomGenerator MOZ_FINAL : public nsIRandomGenerator
{
private:
~nsRandomGenerator() {}
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIRANDOMGENERATOR

View File

@ -61,9 +61,10 @@ public:
NS_DECL_NSIRECENTBADCERTS
nsRecentBadCerts();
~nsRecentBadCerts();
protected:
~nsRecentBadCerts();
mozilla::ReentrantMonitor monitor;
enum {const_recently_seen_list_size = 5};

View File

@ -40,6 +40,8 @@ public:
NS_DECL_NSISECRETDECODERRINGCONFIG
nsSecretDecoderRing();
protected:
virtual ~nsSecretDecoderRing();
private:

View File

@ -19,9 +19,10 @@ class nsSSLSocketProvider : public nsISocketProvider
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSISOCKETPROVIDER
// nsSSLSocketProvider methods:
nsSSLSocketProvider();
protected:
virtual ~nsSSLSocketProvider();
};

View File

@ -19,6 +19,8 @@ class nsSSLStatus
, public nsISerializable
, public nsIClassInfo
{
protected:
virtual ~nsSSLStatus();
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSISSLSTATUS
@ -26,7 +28,6 @@ public:
NS_DECL_NSICLASSINFO
nsSSLStatus();
virtual ~nsSSLStatus();
/* public for initilization in this file */
nsCOMPtr<nsIX509Cert> mServerCert;

View File

@ -26,6 +26,8 @@ public:
// nsTLSSocketProvider methods:
nsTLSSocketProvider();
protected:
virtual ~nsTLSSocketProvider();
};

View File

@ -33,11 +33,13 @@ class nsCertVerificationResult : public nsICertVerificationResult
{
public:
nsCertVerificationResult();
virtual ~nsCertVerificationResult();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSICERTVERIFICATIONRESULT
protected:
virtual ~nsCertVerificationResult();
private:
nsresult mRV;
uint32_t mVerified;