# HG changeset patch # User Kai Engert # Date 1550761461 -3600 # Node ID 40667e32e3601db72cdbc137ba03a3e8f2a293bf # Parent 7e697219f36af588396617a2f33ecc76232d7f7c Bug 1386601 - serialize S/MIME verification using StaticMutex from bug 1522968. r=keeler a=jorgk diff --git a/mailnews/mime/src/nsCMS.cpp b/mailnews/mime/src/nsCMS.cpp --- a/mailnews/mime/src/nsCMS.cpp +++ b/mailnews/mime/src/nsCMS.cpp @@ -20,16 +20,17 @@ #include "nsIX509CertDB.h" #include "nsNSSCertificate.h" #include "nsNSSComponent.h" #include "nsNSSHelper.h" #include "nsServiceManagerUtils.h" #include "mozpkix/Result.h" #include "mozpkix/pkixtypes.h" #include "smime.h" +#include "mozilla/StaticMutex.h" using namespace mozilla; using namespace mozilla::psm; using namespace mozilla::pkix; #ifdef PR_LOGGING extern mozilla::LazyLogModule gPIPNSSLog; #endif @@ -339,16 +340,17 @@ public: mDigestData.Assign(reinterpret_cast(aDigestData), aDigestDataLen); } private: virtual nsresult CalculateResult() override { MOZ_ASSERT(!NS_IsMainThread()); + mozilla::StaticMutexAutoLock lock(sMutex); nsresult rv; if (!mDigestData.IsEmpty()) { rv = mMessage->VerifyDetachedSignature( reinterpret_cast(const_cast(mDigestData.get())), mDigestData.Length()); } else { rv = mMessage->VerifySignature(); } @@ -361,18 +363,23 @@ private: nsCOMPtr m2 = do_QueryInterface(mMessage); mListener->Notify(m2, rv); } nsCOMPtr mMessage; nsCOMPtr mListener; nsCString mDigestData; + + static mozilla::StaticMutex sMutex; + }; +mozilla::StaticMutex SMimeVerificationTask::sMutex; + nsresult nsCMSMessage::CommonAsyncVerifySignature(nsISMimeVerificationListener *aListener, unsigned char* aDigestData, uint32_t aDigestDataLen) { RefPtr task = new SMimeVerificationTask(this, aListener, aDigestData, aDigestDataLen); return task->Dispatch("SMimeVerify"); } class nsZeroTerminatedCertArray