From 5a4e033f1ee46ee1d47ec521ab323bb3ed8c06ef Mon Sep 17 00:00:00 2001 From: Roy Tam Date: Fri, 6 Dec 2019 07:36:57 +0800 Subject: [PATCH] import changes from tenfourfox: - #578: M1322864 M1585106 M1597043 (7758ebb12) - #578: M1579060 M1586176 (f3f295615) --- accessible/generic/RootAccessible.cpp | 9 +++++++++ dom/base/nsContentUtils.cpp | 9 ++++++++- netwerk/base/ProxyAutoConfig.cpp | 17 ++++++++++++----- security/pkix/lib/pkixcert.cpp | 19 +++++++------------ security/pkix/lib/pkixder.h | 11 +++++++++++ 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/accessible/generic/RootAccessible.cpp b/accessible/generic/RootAccessible.cpp index b2077824e..8de0d47f1 100644 --- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -366,6 +366,15 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent) if (FocusMgr()->HasDOMFocus(targetNode)) { nsCOMPtr multiSel = do_QueryInterface(targetNode); + if (!multiSel) { + // This shouldn't be possible. All XUL trees should have + // nsIDOMXULMultiSelectControlElement, and the tree is focused, so it + // shouldn't be dying. Nevertheless, this sometimes happens in the wild + // (bug 1597043). + MOZ_ASSERT_UNREACHABLE( + "XUL tree doesn't have nsIDOMXULMultiSelectControlElement"); + return; + } nsAutoString selType; multiSel->GetSelType(selType); if (selType.IsEmpty() || !selType.EqualsLiteral("single")) { diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 436d764ed..be516d479 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -3184,7 +3184,14 @@ nsContentUtils::GetImageFromContent(nsIImageLoadingContent* aContent, } if (aRequest) { - imgRequest.swap(*aRequest); + // If the consumer wants the request, verify it has actually loaded + // successfully. + uint32_t imgStatus; + imgRequest->GetImageStatus(&imgStatus); + if (imgStatus & imgIRequest::STATUS_FRAME_COMPLETE && + !(imgStatus & imgIRequest::STATUS_ERROR)) { + imgRequest.swap(*aRequest); + } } return imgContainer.forget(); diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 9006f0a75..26701d3ae 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -265,7 +265,8 @@ public: NS_DECL_THREADSAFE_ISUPPORTS PACResolver() - : mStatus(NS_ERROR_FAILURE) + : mStatus(NS_ERROR_FAILURE), + mMutex("PACResolver::Mutex") { } @@ -274,12 +275,17 @@ public: nsIDNSRecord *record, nsresult status) override { - if (mTimer) { - mTimer->Cancel(); - mTimer = nullptr; + nsCOMPtr timer; + { + MutexAutoLock lock(mMutex); + timer.swap(mTimer); + mRequest = nullptr; + } + + if (timer) { + timer->Cancel(); } - mRequest = nullptr; mStatus = status; mResponse = record; return NS_OK; @@ -298,6 +304,7 @@ public: nsCOMPtr mRequest; nsCOMPtr mResponse; nsCOMPtr mTimer; + Mutex mMutex; private: ~PACResolver() {} diff --git a/security/pkix/lib/pkixcert.cpp b/security/pkix/lib/pkixcert.cpp index 1cb452c20..43b52f4ba 100644 --- a/security/pkix/lib/pkixcert.cpp +++ b/security/pkix/lib/pkixcert.cpp @@ -105,29 +105,24 @@ BackCert::Init() return rv; } - static const uint8_t CSC = der::CONTEXT_SPECIFIC | der::CONSTRUCTED; - // According to RFC 5280, all fields below this line are forbidden for // certificate versions less than v3. However, for compatibility reasons, // we parse v1/v2 certificates in the same way as v3 certificates. So if // these fields appear in a v1 certificate, they will be used. // Ignore issuerUniqueID if present. - if (tbsCertificate.Peek(CSC | 1)) { - rv = der::ExpectTagAndSkipValue(tbsCertificate, CSC | 1); - if (rv != Success) { - return rv; - } + rv = der::SkipOptionalImplicitPrimitiveTag(tbsCertificate, 1); + if (rv != Success) { + return rv; } // Ignore subjectUniqueID if present. - if (tbsCertificate.Peek(CSC | 2)) { - rv = der::ExpectTagAndSkipValue(tbsCertificate, CSC | 2); - if (rv != Success) { - return rv; - } + rv = der::SkipOptionalImplicitPrimitiveTag(tbsCertificate, 2); + if (rv != Success) { + return rv; } + static const uint8_t CSC = der::CONTEXT_SPECIFIC | der::CONSTRUCTED; rv = der::OptionalExtensions( tbsCertificate, CSC | 3, [this](Reader& extnID, const Input& extnValue, bool critical, diff --git a/security/pkix/lib/pkixder.h b/security/pkix/lib/pkixder.h index a17114bcb..71691a35e 100644 --- a/security/pkix/lib/pkixder.h +++ b/security/pkix/lib/pkixder.h @@ -123,6 +123,17 @@ ExpectTagAndSkipValue(Reader& input, uint8_t tag) return ExpectTagAndGetValue(input, tag, ignoredValue); } +// This skips IMPLICIT OPTIONAL tags that are "primitive" (not constructed), +// given the number in the class of the tag (i.e. the number in the brackets in +// `issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL`). +inline Result SkipOptionalImplicitPrimitiveTag(Reader& input, + uint8_t numberInClass) { + if (input.Peek(CONTEXT_SPECIFIC | numberInClass)) { + return ExpectTagAndSkipValue(input, CONTEXT_SPECIFIC | numberInClass); + } + return Success; +} + // Like ExpectTagAndGetValue, except the output Input will contain the // encoded tag and length along with the value. inline Result