Skip to content

Commit

Permalink
Bug 1787122 - Fixed assert crash when attempting to get base domain f…
Browse files Browse the repository at this point in the history
…rom 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
  • Loading branch information
edgul committed Aug 30, 2022
1 parent 515bac4 commit 17dc883
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions netwerk/cookie/CookieServiceParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 17dc883

Please sign in to comment.