Bug 1640091 - Make sure DNS requests originating from PAC scripts use TRR_DISABLED_MODE r=kershaw,necko-reviewers

I also considered setting a flag if a PAC query originates from a
TRR service channel but that doesn't work because of this:
1. We try to load test.com -> PAC script
2. We try to load TRR channel -> PAC script with DISABLE_TRR flag
3. PAC thread is still blocked on resolving test.com - we exit early
   regardless of flag

Differential Revision: https://phabricator.services.mozilla.com/D78526
This commit is contained in:
Valentin Gosu 2020-06-08 11:20:04 +00:00
Родитель cc46191834
Коммит 9d2690ae52
1 изменённых файлов: 11 добавлений и 4 удалений

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

@ -441,11 +441,18 @@ bool ProxyAutoConfig::ResolveAddress(const nsCString& aHostName,
RefPtr<PACResolver> helper = new PACResolver(mMainThreadEventTarget);
OriginAttributes attrs;
if (NS_FAILED(dns->AsyncResolveNative(
aHostName, nsIDNSService::RESOLVE_PRIORITY_MEDIUM, helper,
GetCurrentThreadEventTarget(), attrs,
getter_AddRefs(helper->mRequest))))
// When the PAC script attempts to resolve a domain, we must make sure we
// don't use TRR, otherwise the TRR channel might also attempt to resolve
// a name and we'll have a deadlock.
uint32_t flags =
nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
nsIDNSService::GetFlagsFromTRRMode(nsIRequest::TRR_DISABLED_MODE);
if (NS_FAILED(dns->AsyncResolveNative(aHostName, flags, helper,
GetCurrentThreadEventTarget(), attrs,
getter_AddRefs(helper->mRequest)))) {
return false;
}
if (aTimeout && helper->mRequest) {
if (!mTimer) mTimer = NS_NewTimer();