Bug 1026022 - Check that string is UTF8. r=mcmanus

This commit is contained in:
Valentin Gosu 2014-07-02 19:12:19 +03:00
parent c7a48add8e
commit 59b9bc3637

View File

@ -684,8 +684,12 @@ nsDNSService::AsyncResolve(const nsACString &hostname,
nsresult rv;
nsAutoCString hostACE;
if (idn && !IsASCII(*hostPtr)) {
if (NS_SUCCEEDED(idn->ConvertUTF8toACE(*hostPtr, hostACE)))
if (IsUTF8(*hostPtr) &&
NS_SUCCEEDED(idn->ConvertUTF8toACE(*hostPtr, hostACE))) {
hostPtr = &hostACE;
} else {
return NS_ERROR_FAILURE;
}
}
// make sure JS callers get notification on the main thread
@ -747,8 +751,12 @@ nsDNSService::CancelAsyncResolve(const nsACString &aHostname,
nsAutoCString hostACE;
if (idn && !IsASCII(aHostname)) {
if (NS_SUCCEEDED(idn->ConvertUTF8toACE(aHostname, hostACE)))
if (IsUTF8(aHostname) &&
NS_SUCCEEDED(idn->ConvertUTF8toACE(aHostname, hostACE))) {
hostname = hostACE;
} else {
return NS_ERROR_FAILURE;
}
}
uint16_t af = GetAFForLookup(hostname, aFlags);
@ -794,8 +802,12 @@ nsDNSService::Resolve(const nsACString &hostname,
nsresult rv;
nsAutoCString hostACE;
if (idn && !IsASCII(*hostPtr)) {
if (NS_SUCCEEDED(idn->ConvertUTF8toACE(*hostPtr, hostACE)))
if (IsUTF8(*hostPtr) &&
NS_SUCCEEDED(idn->ConvertUTF8toACE(*hostPtr, hostACE))) {
hostPtr = &hostACE;
} else {
return NS_ERROR_FAILURE;
}
}
//