diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index d22ef2c27f..db689e5bc0 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -43,6 +43,7 @@ MSG_DEF(MSG_GLOBAL_NOT_NATIVE, 0, JSEXN_TYPEERR, "Global is not a native object. MSG_DEF(MSG_ENCODING_NOT_SUPPORTED, 1, JSEXN_RANGEERR, "The given encoding '{0}' is not supported.") MSG_DEF(MSG_DOM_ENCODING_NOT_UTF, 0, JSEXN_RANGEERR, "The encoding must be utf-8, utf-16, or utf-16be.") MSG_DEF(MSG_DOM_DECODING_FAILED, 0, JSEXN_TYPEERR, "Decoding failed.") +MSG_DEF(MSG_DOM_OPERATION_FAILED, 0, JSEXN_TYPEERR, "The operation could not be performed.") MSG_DEF(MSG_NOT_FINITE, 1, JSEXN_TYPEERR, "{0} is not a finite floating-point value.") MSG_DEF(MSG_INVALID_VERSION, 0, JSEXN_TYPEERR, "0 (Zero) is not a valid database version.") MSG_DEF(MSG_INVALID_BYTESTRING, 2, JSEXN_TYPEERR, "Cannot convert string to ByteString because the character" diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp index ae172624ca..b5e14f12fd 100644 --- a/dom/crypto/WebCryptoTask.cpp +++ b/dom/crypto/WebCryptoTask.cpp @@ -152,7 +152,7 @@ GetAlgorithmName(JSContext* aCx, const OOS& aAlgorithm, nsString& aName) } if (!NormalizeToken(aName, aName)) { - return NS_ERROR_DOM_SYNTAX_ERR; + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } return NS_OK; @@ -170,7 +170,7 @@ Coerce(JSContext* aCx, T& aTarget, const OOS& aAlgorithm) JS::RootedValue value(aCx, JS::ObjectValue(*aAlgorithm.GetAsObject())); if (!aTarget.Init(aCx, value)) { - return NS_ERROR_DOM_SYNTAX_ERR; + return NS_ERROR_DOM_TYPE_MISMATCH_ERR; } return NS_OK; @@ -401,9 +401,15 @@ WebCryptoTask::FailWithError(nsresult aRv) { MOZ_ASSERT(IsOnOriginalThread()); - // Blindly convert nsresult to DOMException - // Individual tasks must ensure they pass the right values - mResultPromise->MaybeReject(aRv); + if (aRv == NS_ERROR_DOM_TYPE_MISMATCH_ERR) { + ErrorResult rv; + rv.ThrowTypeError(); + mResultPromise->MaybeReject(rv); + } else { + // Blindly convert nsresult to DOMException + // Individual tasks must ensure they pass the right values + mResultPromise->MaybeReject(aRv); + } // Manually release mResultPromise while we're on the main thread mResultPromise = nullptr; mWorkerHolder = nullptr; @@ -1537,7 +1543,8 @@ public: } // Check that we have valid key data. - if (mKeyData.Length() == 0) { + // Zero-length key is allowed for PBKDF2 since it will be padded. + if (mKeyData.Length() == 0 && !mAlgName.EqualsLiteral(WEBCRYPTO_ALG_PBKDF2)) { return NS_ERROR_DOM_DATA_ERR; } @@ -2206,7 +2213,6 @@ public: nsString algName; mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, algName); if (NS_FAILED(mEarlyRv)) { - mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR; return; } @@ -2235,7 +2241,6 @@ public: nsString hashName; mEarlyRv = GetAlgorithmName(aCx, params.mHash, hashName); if (NS_FAILED(mEarlyRv)) { - mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR; return; } @@ -2333,7 +2338,6 @@ GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask( // Extract algorithm name mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, mAlgName); if (NS_FAILED(mEarlyRv)) { - mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR; return; } @@ -2356,7 +2360,6 @@ GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask( nsString hashName; mEarlyRv = GetAlgorithmName(aCx, params.mHash, hashName); if (NS_FAILED(mEarlyRv)) { - mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR; return; } @@ -2734,12 +2737,6 @@ public: { CHECK_KEY_ALGORITHM(aKey.Algorithm(), WEBCRYPTO_ALG_PBKDF2); - // Check that we got a symmetric key - if (mSymKey.Length() == 0) { - mEarlyRv = NS_ERROR_DOM_INVALID_ACCESS_ERR; - return; - } - RootedDictionary params(aCx); mEarlyRv = Coerce(aCx, params, aAlgorithm); if (NS_FAILED(mEarlyRv)) { @@ -2747,9 +2744,9 @@ public: return; } - // length must be a multiple of 8 bigger than zero. + // Length must be a multiple of 8 bigger than zero. if (aLength == 0 || aLength % 8) { - mEarlyRv = NS_ERROR_DOM_DATA_ERR; + mEarlyRv = NS_ERROR_DOM_OPERATION_ERR; return; } @@ -2926,7 +2923,7 @@ public: RootedDictionary params(aCx); mEarlyRv = Coerce(aCx, params, aAlgorithm); if (NS_FAILED(mEarlyRv)) { - mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR; + /* The returned code is installed by Coerce function. */ return; } @@ -3573,6 +3570,7 @@ WebCryptoTask::CreateUnwrapKeyTask(nsIGlobalObject* aGlobal, if (keyAlgName.EqualsASCII(WEBCRYPTO_ALG_AES_CBC) || keyAlgName.EqualsASCII(WEBCRYPTO_ALG_AES_CTR) || keyAlgName.EqualsASCII(WEBCRYPTO_ALG_AES_GCM) || + keyAlgName.EqualsASCII(WEBCRYPTO_ALG_AES_KW) || keyAlgName.EqualsASCII(WEBCRYPTO_ALG_HKDF) || keyAlgName.EqualsASCII(WEBCRYPTO_ALG_HMAC)) { importTask = new ImportSymmetricKeyTask(aGlobal, aCx, aFormat, diff --git a/dom/url/URL.cpp b/dom/url/URL.cpp index f594c0f322..9586d46c5f 100644 --- a/dom/url/URL.cpp +++ b/dom/url/URL.cpp @@ -61,10 +61,6 @@ CreateObjectURLInternal(const GlobalObject& aGlobal, T aObject, class URLMainThread final : public URL { public: - static already_AddRefed - Constructor(const GlobalObject& aGlobal, const nsAString& aURL, - URL& aBase, ErrorResult& aRv); - static already_AddRefed Constructor(const GlobalObject& aGlobal, const nsAString& aURL, const Optional& aBase, ErrorResult& aRv); @@ -196,15 +192,6 @@ private: nsCOMPtr mURI; }; -/* static */ already_AddRefed -URLMainThread::Constructor(const GlobalObject& aGlobal, const nsAString& aURL, - URL& aBase, ErrorResult& aRv) -{ - MOZ_ASSERT(NS_IsMainThread()); - URLMainThread& base = static_cast(aBase); - return Constructor(aGlobal.GetAsSupports(), aURL, base.GetURI(), aRv); -} - /* static */ already_AddRefed URLMainThread::Constructor(const GlobalObject& aGlobal, const nsAString& aURL, const Optional& aBase, ErrorResult& aRv) @@ -639,10 +626,6 @@ private: class URLWorker final : public URL { public: - static already_AddRefed - Constructor(const GlobalObject& aGlobal, const nsAString& aURL, - URL& aBase, ErrorResult& aRv); - static already_AddRefed Constructor(const GlobalObject& aGlobal, const nsAString& aURL, const Optional& aBase, ErrorResult& aRv); @@ -934,7 +917,6 @@ private: const nsString mURL; nsString mBase; // IsVoid() if we have no base URI string. - RefPtr mBaseProxy; RefPtr mRetval; @@ -953,17 +935,6 @@ public: mWorkerPrivate->AssertIsOnWorkerThread(); } - ConstructorRunnable(WorkerPrivate* aWorkerPrivate, - const nsAString& aURL, URLProxy* aBaseProxy) - : WorkerMainThreadRunnable(aWorkerPrivate, - NS_LITERAL_CSTRING("URL :: Constructor with BaseURL")) - , mURL(aURL) - , mBaseProxy(aBaseProxy) - { - mBase.SetIsVoid(true); - mWorkerPrivate->AssertIsOnWorkerThread(); - } - bool MainThreadRun() { @@ -971,9 +942,7 @@ public: ErrorResult rv; RefPtr url; - if (mBaseProxy) { - url = URLMainThread::Constructor(nullptr, mURL, mBaseProxy->URI(), rv); - } else if (!mBase.IsVoid()) { + if (!mBase.IsVoid()) { url = URLMainThread::Constructor(nullptr, mURL, mBase, rv); } else { url = URLMainThread::Constructor(nullptr, mURL, nullptr, rv); @@ -1249,22 +1218,6 @@ FinishConstructor(JSContext* aCx, WorkerPrivate* aPrivate, return url.forget(); } -/* static */ already_AddRefed -URLWorker::Constructor(const GlobalObject& aGlobal, const nsAString& aURL, - URL& aBase, ErrorResult& aRv) -{ - MOZ_ASSERT(!NS_IsMainThread()); - - JSContext* cx = aGlobal.Context(); - WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx); - - URLWorker& base = static_cast(aBase); - RefPtr runnable = - new ConstructorRunnable(workerPrivate, aURL, base.GetURLProxy()); - - return FinishConstructor(cx, workerPrivate, runnable, aRv); -} - /* static */ already_AddRefed URLWorker::Constructor(const GlobalObject& aGlobal, const nsAString& aURL, const Optional& aBase, ErrorResult& aRv) @@ -1688,17 +1641,6 @@ URL::WrapObject(JSContext* aCx, JS::Handle aGivenProto) return URLBinding::Wrap(aCx, this, aGivenProto); } -/* static */ already_AddRefed -URL::Constructor(const GlobalObject& aGlobal, const nsAString& aURL, - URL& aBase, ErrorResult& aRv) -{ - if (NS_IsMainThread()) { - return URLMainThread::Constructor(aGlobal, aURL, aBase, aRv); - } - - return URLWorker::Constructor(aGlobal, aURL, aBase, aRv); -} - /* static */ already_AddRefed URL::Constructor(const GlobalObject& aGlobal, const nsAString& aURL, const Optional& aBase, ErrorResult& aRv) diff --git a/dom/url/URL.h b/dom/url/URL.h index 53164b7b95..13a76d7198 100644 --- a/dom/url/URL.h +++ b/dom/url/URL.h @@ -47,10 +47,6 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; - static already_AddRefed - Constructor(const GlobalObject& aGlobal, const nsAString& aURL, - URL& aBase, ErrorResult& aRv); - static already_AddRefed Constructor(const GlobalObject& aGlobal, const nsAString& aURL, const Optional& aBase, ErrorResult& aRv); diff --git a/dom/webidl/URL.webidl b/dom/webidl/URL.webidl index a12635ce3f..25cf9368d4 100644 --- a/dom/webidl/URL.webidl +++ b/dom/webidl/URL.webidl @@ -12,9 +12,7 @@ * liability, trademark and document use rules apply. */ -// [Constructor(DOMString url, optional (URL or DOMString) base = "about:blank")] -[Constructor(DOMString url, URL base), - Constructor(DOMString url, optional DOMString base), +[Constructor(DOMString url, optional DOMString base), NamedConstructor=webkitURL(DOMString url, optional DOMString base), Exposed=(Window,Worker,WorkerDebugger)] interface URL { diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 0df80716c1..867bc53392 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -604,6 +604,9 @@ txMozillaXSLTProcessor::ImportStylesheet(nsIDOMNode *aStyle) NS_ENSURE_TRUE(!mStylesheetDocument && !mStylesheet, NS_ERROR_NOT_IMPLEMENTED); + // Reset mCompileResult when importing. + mCompileResult = NS_OK; + nsCOMPtr node = do_QueryInterface(aStyle); if (!node || !nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->Subsumes(node->NodePrincipal())) { return NS_ERROR_DOM_SECURITY_ERR; diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index e5d4779361..25e9e93b3b 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -1059,6 +1059,11 @@ JSStructuredCloneWriter::reportDataCloneError(uint32_t errorId) bool JSStructuredCloneWriter::writeString(uint32_t tag, JSString* str) { + // Nullcheck input + if (!str) { + return false; + } + JSLinearString* linear = str->ensureLinear(context()); if (!linear) return false; @@ -1079,8 +1084,11 @@ JSStructuredCloneWriter::writeString(uint32_t tag, JSString* str) bool JSStructuredCloneWriter::writeBigInt(uint32_t tag, BigInt* bi) { - if (!bi) - return false; + // Nullcheck input + if (!bi) { + return false; + } + bool signBit = bi->isNegative(); size_t length = bi->digitLength(); // The length must fit in 31 bits to leave room for a sign bit. diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 13e6ec3570..e25a8b43f9 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -25,7 +25,7 @@ pref("general.useragent.locale", "chrome://global/locale/intl.properties"); // Platform User-agent compatibility mode default settings pref("general.useragent.compatMode.gecko", false); pref("general.useragent.compatMode.firefox", false); -pref("general.useragent.compatMode.version", "102.0"); +pref("general.useragent.compatMode.version", "115.0"); pref("general.useragent.appVersionIsBuildID", false); pref("general.useragent.change_platform_version", true); pref("general.useragent.platform_version", "6.7"); diff --git a/old-configure.in b/old-configure.in index 5e58cd5dfe..a2ad1712a1 100644 --- a/old-configure.in +++ b/old-configure.in @@ -221,6 +221,9 @@ case "$target" in # 'noexcept' used with no exception handling mode specified; # termination on exception is not guaranteed. Specify /EHsc CXXFLAGS="$CXXFLAGS -wd4577" + + # Silence unhelpful -Qspectre warnings + CXXFLAGS="$CXXFLAGS -wd5045" if test -n "$WIN_UCRT_REDIST_DIR"; then if test ! -d "$WIN_UCRT_REDIST_DIR"; then diff --git a/security/nss/lib/dev/devutil.c b/security/nss/lib/dev/devutil.c index a6bbb93207..b69a95aae9 100644 --- a/security/nss/lib/dev/devutil.c +++ b/security/nss/lib/dev/devutil.c @@ -577,9 +577,11 @@ get_token_objects_for_cache( } else { PRUint32 j; for (j = 0; j < i; j++) { - /* Any token references that were removed in successful loop iterations - * need to be restored before we call nssCryptokiObjectArray_Destroy */ - nssToken_AddRef(cache->objects[objectType][j]->object->token); + /* Objects that were successfully added to the cache do not own a + * token reference (they share a reference with the cache itself). + * Nulling out the pointer here prevents the token's refcount + * from being decremented in nssCryptokiObject_Destroy */ + cache->objects[objectType][j]->object->token = NULL; nssArena_Destroy(cache->objects[objectType][j]->arena); } nss_ZFreeIf(cache->objects[objectType]); diff --git a/security/nss/lib/pkcs7/certread.c b/security/nss/lib/pkcs7/certread.c index 15094f2d78..1d44e0e38e 100644 --- a/security/nss/lib/pkcs7/certread.c +++ b/security/nss/lib/pkcs7/certread.c @@ -520,6 +520,8 @@ CERT_DecodeCertFromPackage(char *certbuf, int certlen) CERTCertificate *cert = NULL; collectArgs.arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); + collectArgs.cert.data = NULL; + collectArgs.cert.len = 0; rv = CERT_DecodeCertPackage(certbuf, certlen, collect_certs, (void *)&collectArgs);