Bug 1386601 - serialize S/MIME verification using StaticMutex from bug 1522968. r=keeler a=jorgk THUNDERBIRD_60_5_2_BUILD1 THUNDERBIRD_60_5_2_RELEASE
authorKai Engert <kaie@kuix.de>
Thu, 21 Feb 2019 16:04:21 +0100
changeset 32093 40667e32e3601db72cdbc137ba03a3e8f2a293bf
parent 32092 1a5b3ce230b6ef6dc1fa914c76b56f9e7d7e8428
child 32094 529c038da90898efcb38260e9b8f077b5b8e23d8
push id157
push usermozilla@jorgk.com
push dateThu, 21 Feb 2019 15:05:24 +0000
treeherdercomm-esr60@40667e32e360 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler, jorgk
bugs1386601, 1522968
Bug 1386601 - serialize S/MIME verification using StaticMutex from bug 1522968. r=keeler a=jorgk
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 "pkix/Result.h"
 #include "pkix/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
@@ -385,16 +386,17 @@ public:
     mDigestType = aDigestType;
   }
 
 private:
   virtual nsresult CalculateResult() override
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
+    mozilla::StaticMutexAutoLock lock(sMutex);
     nsresult rv;
     if (!mDigestData.IsEmpty()) {
       rv = mMessage->VerifyDetachedSignature(
         reinterpret_cast<uint8_t*>(const_cast<char *>(mDigestData.get())),
         mDigestData.Length(), mDigestType);
     } else {
       rv = mMessage->VerifySignature();
     }
@@ -408,18 +410,22 @@ private:
     nsCOMPtr<nsICMSMessage2> m2 = do_QueryInterface(mMessage);
     mListener->Notify(m2, rv);
   }
 
   nsCOMPtr<nsICMSMessage> mMessage;
   nsCOMPtr<nsISMimeVerificationListener> mListener;
   nsCString mDigestData;
   int16_t mDigestType;
+
+  static mozilla::StaticMutex sMutex;
 };
 
+mozilla::StaticMutex SMimeVerificationTask::sMutex;
+
 nsresult nsCMSMessage::CommonAsyncVerifySignature(nsISMimeVerificationListener *aListener,
                                                   unsigned char* aDigestData, uint32_t aDigestDataLen,
                                                   int16_t aDigestType)
 {
   RefPtr<CryptoTask> task = new SMimeVerificationTask(this, aListener, aDigestData, aDigestDataLen, aDigestType);
   return task->Dispatch("SMimeVerify");
 }