Bug 1787122 - Fixed assert crash when attempting to get base domain from a malformed URL. r=kershaw

Testing will be completed in: https://bugzilla.mozilla.org/show_bug.cgi?id=1788080

Differential Revision: https://phabricator.services.mozilla.com/D155878
This commit is contained in:
edgul 2022-08-30 16:49:43 +00:00
Родитель 515bac47be
Коммит 17dc8833aa
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -82,6 +82,7 @@ void CookieServiceParent::AddCookie(const Cookie& cookie) {
bool CookieServiceParent::CookieMatchesContentList(const Cookie& cookie) {
nsCString baseDomain;
// CookieStorage notifications triggering this won't fail to get base domain
MOZ_ALWAYS_SUCCEEDS(CookieCommons::GetBaseDomainFromHost(
mTLDService, cookie.Host(), baseDomain));
@ -135,8 +136,12 @@ void CookieServiceParent::UpdateCookieInContentList(
nsIURI* uri, const OriginAttributes& originAttrs) {
nsCString baseDomain;
bool requireAHostMatch = false;
MOZ_ALWAYS_SUCCEEDS(CookieCommons::GetBaseDomain(mTLDService, uri, baseDomain,
requireAHostMatch));
// prevent malformed urls from being added to the cookie list
if (NS_WARN_IF(NS_FAILED(CookieCommons::GetBaseDomain(
mTLDService, uri, baseDomain, requireAHostMatch)))) {
return;
}
CookieKey cookieKey(baseDomain, originAttrs);
bool& allowSecure = mCookieKeysInContent.LookupOrInsert(cookieKey, false);