Bug 394525: malware check non-http channels. r=bz, sr=biesi

This commit is contained in:
dcamp%mozilla.com 2007-11-27 20:42:33 +00:00
Родитель 50d74a36ed
Коммит 73ee5ba20e
1 изменённых файлов: 26 добавлений и 7 удалений

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

@ -9262,12 +9262,25 @@ nsClassifierCallback::Run()
nsresult rv = channel->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
// XXX: we need to audit other channels to make sure they can handle
// being suspended directly after AsyncOpen()
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
if (!httpChannel) {
return NS_OK;
}
// Don't bother checking certain types of URIs.
PRBool hasFlags;
rv = NS_URIChainHasFlags(uri,
nsIProtocolHandler::URI_DANGEROUS_TO_LOAD,
&hasFlags);
NS_ENSURE_SUCCESS(rv, rv);
if (hasFlags) return NS_OK;
rv = NS_URIChainHasFlags(uri,
nsIProtocolHandler::URI_IS_LOCAL_FILE,
&hasFlags);
NS_ENSURE_SUCCESS(rv, rv);
if (hasFlags) return NS_OK;
rv = NS_URIChainHasFlags(uri,
nsIProtocolHandler::URI_IS_UI_RESOURCE,
&hasFlags);
NS_ENSURE_SUCCESS(rv, rv);
if (hasFlags) return NS_OK;
nsCOMPtr<nsIURIClassifier> uriClassifier =
do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv);
@ -9281,7 +9294,13 @@ nsClassifierCallback::Run()
// Suspend the channel, it will be resumed when we get the classifier
// callback.
rv = channel->Suspend();
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
// Some channels (including nsJSChannel) fail on Suspend. This
// shouldn't be fatal, but will prevent malware from being
// blocked on these channels.
return NS_OK;
}
mSuspendedChannel = channel;
#ifdef DEBUG
PR_LOG(gDocShellLog, PR_LOG_DEBUG,