зеркало из https://github.com/mozilla/gecko-dev.git
bug 857291 - fix 807678 regression of DNS::GetCanonicalName r=josh
This commit is contained in:
Родитель
b0d7171a54
Коммит
29a49dbb09
|
@ -176,11 +176,19 @@ NetAddrElement::~NetAddrElement()
|
|||
}
|
||||
|
||||
AddrInfo::AddrInfo(const char *host, const PRAddrInfo *prAddrInfo,
|
||||
bool disableIPv4)
|
||||
bool disableIPv4, const char *cname)
|
||||
{
|
||||
size_t hostlen = strlen(host);
|
||||
mHostName = static_cast<char*>(moz_xmalloc(hostlen + 1));
|
||||
memcpy(mHostName, host, hostlen + 1);
|
||||
if (cname) {
|
||||
size_t cnameLen = strlen(cname);
|
||||
mCanonicalName = static_cast<char*>(moz_xmalloc(cnameLen + 1));
|
||||
memcpy(mCanonicalName, cname, cnameLen + 1);
|
||||
}
|
||||
else {
|
||||
mCanonicalName = nullptr;
|
||||
}
|
||||
|
||||
PRNetAddr tmpAddr;
|
||||
void *iter = nullptr;
|
||||
|
@ -200,6 +208,7 @@ AddrInfo::~AddrInfo()
|
|||
delete addrElement;
|
||||
}
|
||||
moz_free(mHostName);
|
||||
moz_free(mCanonicalName);
|
||||
}
|
||||
|
||||
} // namespace dns
|
||||
|
|
|
@ -121,10 +121,12 @@ public:
|
|||
|
||||
class AddrInfo {
|
||||
public:
|
||||
AddrInfo(const char *host, const PRAddrInfo *prAddrInfo, bool disableIPv4);
|
||||
AddrInfo(const char *host, const PRAddrInfo *prAddrInfo, bool disableIPv4,
|
||||
const char *cname);
|
||||
~AddrInfo();
|
||||
|
||||
char *mHostName;
|
||||
char *mCanonicalName;
|
||||
LinkedList<NetAddrElement> mAddresses;
|
||||
};
|
||||
|
||||
|
|
|
@ -83,7 +83,9 @@ nsDNSRecord::GetCanonicalName(nsACString &result)
|
|||
{
|
||||
MutexAutoLock lock(mHostRecord->addr_info_lock);
|
||||
if (mHostRecord->addr_info)
|
||||
cname = mHostRecord->addr_info->mHostName;
|
||||
cname = mHostRecord->addr_info->mCanonicalName ?
|
||||
mHostRecord->addr_info->mCanonicalName :
|
||||
mHostRecord->addr_info->mHostName;
|
||||
else
|
||||
cname = mHostRecord->host;
|
||||
result.Assign(cname);
|
||||
|
|
|
@ -997,7 +997,10 @@ nsHostResolver::ThreadFunc(void *arg)
|
|||
nsresult status;
|
||||
AddrInfo *ai = nullptr;
|
||||
if (prai) {
|
||||
ai = new AddrInfo(rec->host, prai, disableIPv4);
|
||||
const char *cname = nullptr;
|
||||
if (rec->flags & RES_CANON_NAME)
|
||||
cname = PR_GetCanonNameFromAddrInfo(prai);
|
||||
ai = new AddrInfo(rec->host, prai, disableIPv4, cname);
|
||||
PR_FreeAddrInfo(prai);
|
||||
if (ai->mAddresses.isEmpty()) {
|
||||
delete ai;
|
||||
|
|
Загрузка…
Ссылка в новой задаче