mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Backed out 2 changesets (bug 1708116) for causing build bustages. CLOSED TREE
Backed out changeset d1488e9d64a6 (bug 1708116) Backed out changeset 44ed91f0b7b4 (bug 1708116)
This commit is contained in:
parent
0ff1bef46b
commit
f7b8c6b3d1
@ -82,7 +82,9 @@ already_AddRefed<UDPSocket> UDPSocket::Constructor(const GlobalObject& aGlobal,
|
||||
|
||||
// check if localAddress is a valid IPv4/6 address
|
||||
NS_ConvertUTF16toUTF8 address(localAddress);
|
||||
if (!net::HostIsIPLiteral(address)) {
|
||||
PRNetAddr prAddr;
|
||||
PRStatus status = PR_StringToNetAddr(address.BeginReading(), &prAddr);
|
||||
if (status != PR_SUCCESS) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -578,10 +578,18 @@ bool nsHTTPSOnlyUtils::LoopbackOrLocalException(nsIURI* aURI) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mozilla::net::NetAddr addr;
|
||||
if (NS_FAILED(addr.InitFromString(asciiHost))) {
|
||||
// The local-ip and loopback checks expect a NetAddr struct. We only have a
|
||||
// host-string but can convert it to a NetAddr by first converting it to
|
||||
// PRNetAddr.
|
||||
PRNetAddr tempAddr;
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
// PR_StringToNetAddr does not properly initialize the output buffer in the
|
||||
// case of IPv6 input. See bug 223145.
|
||||
if (PR_StringToNetAddr(asciiHost.get(), &tempAddr) != PR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mozilla::net::NetAddr addr(&tempAddr);
|
||||
// Loopback IPs are always exempt
|
||||
if (addr.IsLoopbackAddr()) {
|
||||
return true;
|
||||
|
@ -233,12 +233,17 @@ bool nsMixedContentBlocker::IsPotentiallyTrustworthyLoopbackHost(
|
||||
return true;
|
||||
}
|
||||
|
||||
using namespace mozilla::net;
|
||||
NetAddr addr;
|
||||
if (NS_FAILED(addr.InitFromString(aAsciiHost))) {
|
||||
PRNetAddr tempAddr;
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
if (PR_StringToNetAddr(PromiseFlatCString(aAsciiHost).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
using namespace mozilla::net;
|
||||
NetAddr addr(&tempAddr);
|
||||
|
||||
// Step 4 of
|
||||
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy says
|
||||
// we should only consider [::1]/128 as a potentially trustworthy IPv6
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/net/HttpAuthUtils.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
|
||||
using mozilla::Base64Decode;
|
||||
|
||||
@ -565,16 +564,13 @@ bool nsHttpNegotiateAuth::TestBoolPref(const char* pref) {
|
||||
|
||||
bool nsHttpNegotiateAuth::TestNonFqdn(nsIURI* uri) {
|
||||
nsAutoCString host;
|
||||
PRNetAddr addr;
|
||||
|
||||
if (!TestBoolPref(kNegotiateAuthAllowNonFqdn)) {
|
||||
return false;
|
||||
}
|
||||
if (!TestBoolPref(kNegotiateAuthAllowNonFqdn)) return false;
|
||||
|
||||
if (NS_FAILED(uri->GetAsciiHost(host))) {
|
||||
return false;
|
||||
}
|
||||
if (NS_FAILED(uri->GetAsciiHost(host))) return false;
|
||||
|
||||
// return true if host does not contain a dot and is not an ip address
|
||||
return !host.IsEmpty() && !host.Contains('.') &&
|
||||
!mozilla::net::HostIsIPLiteral(host);
|
||||
PR_StringToNetAddr(host.BeginReading(), &addr) != PR_SUCCESS;
|
||||
}
|
||||
|
@ -128,15 +128,17 @@ already_AddRefed<AddrInfo> NetworkConnectivityService::MapNAT64IPs(
|
||||
// Returns true if a prefix was read and saved to the argument
|
||||
static inline bool NAT64PrefixFromPref(NetAddr* prefix) {
|
||||
nsAutoCString nat64PrefixPref;
|
||||
PRNetAddr prAddr{};
|
||||
|
||||
nsresult rv = Preferences::GetCString(
|
||||
"network.connectivity-service.nat64-prefix", nat64PrefixPref);
|
||||
if (NS_FAILED(rv) || nat64PrefixPref.IsEmpty() ||
|
||||
NS_FAILED(prefix->InitFromString(nat64PrefixPref)) ||
|
||||
prefix->raw.family != PR_AF_INET6) {
|
||||
PR_StringToNetAddr(nat64PrefixPref.get(), &prAddr) != PR_SUCCESS ||
|
||||
prAddr.raw.family != PR_AF_INET6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PRNetAddrToNetAddr(&prAddr, prefix);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -980,7 +980,9 @@ bool ProxyAutoConfig::MyIPAddress(const JS::CallArgs& aArgs) {
|
||||
}
|
||||
} else {
|
||||
// we can still do the fancy multi homing thing if the host is a literal
|
||||
if (HostIsIPLiteral(mRunningHost) &&
|
||||
PRNetAddr tempAddr;
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
if ((PR_StringToNetAddr(mRunningHost.get(), &tempAddr) == PR_SUCCESS) &&
|
||||
(!MyIPAddressTryHost(mRunningHost, kTimeout, aArgs, &rvalAssigned) ||
|
||||
rvalAssigned)) {
|
||||
return rvalAssigned;
|
||||
|
@ -743,10 +743,16 @@ nsresult nsIOService::RecheckCaptivePortalIfLocalRedirect(nsIChannel* newChan) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
NetAddr addr;
|
||||
// If the redirect wasn't to an IP literal, so there's probably no need
|
||||
// to trigger the captive portal detection right now. It can wait.
|
||||
if (NS_SUCCEEDED(addr.InitFromString(host)) && addr.IsIPAddrLocal()) {
|
||||
PRNetAddr prAddr;
|
||||
if (PR_StringToNetAddr(host.BeginReading(), &prAddr) != PR_SUCCESS) {
|
||||
// The redirect wasn't to an IP literal, so there's probably no need
|
||||
// to trigger the captive portal detection right now. It can wait.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NetAddr netAddr(&prAddr);
|
||||
if (netAddr.IsIPAddrLocal()) {
|
||||
// Redirects to local IP addresses are probably captive portals
|
||||
RecheckCaptivePortal();
|
||||
}
|
||||
|
||||
@ -941,9 +947,13 @@ nsIOService::HostnameIsLocalIPAddress(nsIURI* aURI, bool* aResult) {
|
||||
|
||||
*aResult = false;
|
||||
|
||||
NetAddr addr;
|
||||
if (NS_SUCCEEDED(addr.InitFromString(host)) && addr.IsIPAddrLocal()) {
|
||||
*aResult = true;
|
||||
PRNetAddr addr;
|
||||
PRStatus result = PR_StringToNetAddr(host.get(), &addr);
|
||||
if (result == PR_SUCCESS) {
|
||||
NetAddr netAddr(&addr);
|
||||
if (netAddr.IsIPAddrLocal()) {
|
||||
*aResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -964,9 +974,13 @@ nsIOService::HostnameIsSharedIPAddress(nsIURI* aURI, bool* aResult) {
|
||||
|
||||
*aResult = false;
|
||||
|
||||
NetAddr addr;
|
||||
if (NS_SUCCEEDED(addr.InitFromString(host)) && addr.IsIPAddrShared()) {
|
||||
*aResult = true;
|
||||
PRNetAddr addr;
|
||||
PRStatus result = PR_StringToNetAddr(host.get(), &addr);
|
||||
if (result == PR_SUCCESS) {
|
||||
NetAddr netAddr(&addr);
|
||||
if (netAddr.IsIPAddrShared()) {
|
||||
*aResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -519,19 +519,30 @@ nsUDPSocket::Init2(const nsACString& aAddr, int32_t aPort,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
PRNetAddr prAddr;
|
||||
memset(&prAddr, 0, sizeof(prAddr));
|
||||
if (PR_StringToNetAddr(aAddr.BeginReading(), &prAddr) != PR_SUCCESS) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPort < 0) {
|
||||
aPort = 0;
|
||||
}
|
||||
|
||||
NetAddr addr;
|
||||
if (NS_FAILED(addr.InitFromString(aAddr, uint16_t(aPort)))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
switch (prAddr.raw.family) {
|
||||
case PR_AF_INET:
|
||||
prAddr.inet.port = PR_htons(aPort);
|
||||
break;
|
||||
case PR_AF_INET6:
|
||||
prAddr.ipv6.port = PR_htons(aPort);
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Dont accept address other than IPv4 and IPv6");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
if (addr.raw.family != PR_AF_INET && addr.raw.family != PR_AF_INET6) {
|
||||
MOZ_ASSERT_UNREACHABLE("Dont accept address other than IPv4 and IPv6");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
NetAddr addr;
|
||||
PRNetAddrToNetAddr(&prAddr, &addr);
|
||||
|
||||
return InitWithAddress(&addr, aPrincipal, aAddressReuse, aOptionalArgc);
|
||||
}
|
||||
|
@ -888,7 +888,9 @@ bool net_IsValidHostName(const nsACString& host) {
|
||||
return true;
|
||||
|
||||
// Might be a valid IPv6 link-local address containing a percent sign
|
||||
return HostIsIPLiteral(host);
|
||||
nsAutoCString strhost(host);
|
||||
PRNetAddr addr;
|
||||
return PR_StringToNetAddr(strhost.get(), &addr) == PR_SUCCESS;
|
||||
}
|
||||
|
||||
bool net_IsValidIPv4Addr(const nsACString& aAddr) {
|
||||
|
@ -179,11 +179,6 @@ bool IsLoopbackHostname(const nsACString& aAsciiHost) {
|
||||
StringEndsWith(host, ".localhost"_ns);
|
||||
}
|
||||
|
||||
bool HostIsIPLiteral(const nsACString& aAsciiHost) {
|
||||
NetAddr addr;
|
||||
return NS_SUCCEEDED(addr.InitFromString(aAsciiHost));
|
||||
}
|
||||
|
||||
bool NetAddr::IsIPAddrAny() const {
|
||||
if (this->raw.family == AF_INET) {
|
||||
if (this->inet.ip == htonl(INADDR_ANY)) {
|
||||
@ -203,25 +198,6 @@ bool NetAddr::IsIPAddrAny() const {
|
||||
|
||||
NetAddr::NetAddr(const PRNetAddr* prAddr) { PRNetAddrToNetAddr(prAddr, this); }
|
||||
|
||||
nsresult NetAddr::InitFromString(const nsACString& aString, uint16_t aPort) {
|
||||
const nsPromiseFlatCString& flat = PromiseFlatCString(aString);
|
||||
PRNetAddr prAddr{};
|
||||
if (PR_StringToNetAddr(flat.get(), &prAddr) != PR_SUCCESS) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRNetAddrToNetAddr(&prAddr, this);
|
||||
|
||||
if (aPort) {
|
||||
if (this->raw.family == PR_AF_INET) {
|
||||
this->inet.port = PR_htons(aPort);
|
||||
} else if (this->raw.family == PR_AF_INET6) {
|
||||
this->inet6.port = PR_htons(aPort);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool NetAddr::IsIPAddrV4() const { return this->raw.family == AF_INET; }
|
||||
|
||||
bool NetAddr::IsIPAddrV4Mapped() const {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "prnetdb.h"
|
||||
#include "plstr.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
@ -139,12 +140,6 @@ union NetAddr {
|
||||
NetAddr() { memset(this, 0, sizeof(NetAddr)); }
|
||||
explicit NetAddr(const PRNetAddr* prAddr);
|
||||
|
||||
// Will parse aString into a NetAddr using PR_StringToNetAddr.
|
||||
// Returns an error code if parsing fails.
|
||||
// If aPort is non-0 will set the NetAddr's port to (the network endian
|
||||
// value of) that.
|
||||
nsresult InitFromString(const nsACString& aString, uint16_t aPort = 0);
|
||||
|
||||
bool IsIPAddrAny() const;
|
||||
bool IsLoopbackAddr() const;
|
||||
bool IsLoopBackAddressWithoutIPv6Mapping() const;
|
||||
@ -287,8 +282,6 @@ void NetAddrToPRNetAddr(const NetAddr* addr, PRNetAddr* prAddr);
|
||||
|
||||
bool IsLoopbackHostname(const nsACString& aAsciiHost);
|
||||
|
||||
bool HostIsIPLiteral(const nsACString& aAsciiHost);
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -312,7 +312,8 @@ bool FindAddrOverride(const nsACString& aHost, uint16_t aAddressFamily,
|
||||
if (aAddressFamily != AF_UNSPEC && ip.raw.family != aAddressFamily) {
|
||||
continue;
|
||||
}
|
||||
addresses.AppendElement(ip);
|
||||
NetAddr addr(&ip);
|
||||
addresses.AppendElement(addr);
|
||||
}
|
||||
|
||||
if (!cname) {
|
||||
@ -411,7 +412,10 @@ NS_IMPL_ISUPPORTS(NativeDNSResolverOverride, nsINativeDNSResolverOverride)
|
||||
|
||||
NS_IMETHODIMP NativeDNSResolverOverride::AddIPOverride(
|
||||
const nsACString& aHost, const nsACString& aIPLiteral) {
|
||||
NetAddr tempAddr;
|
||||
PRNetAddr tempAddr;
|
||||
// Unfortunately, PR_StringToNetAddr does not properly initialize
|
||||
// the output buffer in the case of IPv6 input. See bug 223145.
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
if (aIPLiteral.Equals("N/A"_ns)) {
|
||||
AutoWriteLock lock(mLock);
|
||||
@ -420,7 +424,8 @@ NS_IMETHODIMP NativeDNSResolverOverride::AddIPOverride(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_FAILED(tempAddr.InitFromString(aIPLiteral))) {
|
||||
if (PR_StringToNetAddr(nsCString(aIPLiteral).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "mozilla/RWLock.h"
|
||||
#include "nsTArray.h"
|
||||
#include "prio.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
# define DNSQUERY_AVAILABLE 1
|
||||
@ -75,7 +74,7 @@ class NativeDNSResolverOverride : public nsINativeDNSResolverOverride {
|
||||
virtual ~NativeDNSResolverOverride() = default;
|
||||
mozilla::RWLock mLock{"NativeDNSResolverOverride"};
|
||||
|
||||
nsTHashMap<nsCStringHashKey, nsTArray<NetAddr>> mOverrides;
|
||||
nsTHashMap<nsCStringHashKey, nsTArray<PRNetAddr>> mOverrides;
|
||||
nsTHashMap<nsCStringHashKey, nsCString> mCnames;
|
||||
|
||||
friend bool FindAddrOverride(const nsACString& aHost, uint16_t aAddressFamily,
|
||||
|
@ -43,9 +43,14 @@ NativeDNSResolverOverrideParent::GetSingleton() {
|
||||
|
||||
NS_IMETHODIMP NativeDNSResolverOverrideParent::AddIPOverride(
|
||||
const nsACString& aHost, const nsACString& aIPLiteral) {
|
||||
NetAddr tempAddr;
|
||||
PRNetAddr tempAddr;
|
||||
// Unfortunately, PR_StringToNetAddr does not properly initialize
|
||||
// the output buffer in the case of IPv6 input. See bug 223145.
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
if (!aIPLiteral.Equals("N/A"_ns) &&
|
||||
NS_FAILED(tempAddr.InitFromString(aIPLiteral))) {
|
||||
PR_StringToNetAddr(nsCString(aIPLiteral).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -503,8 +503,9 @@ nsresult TRR::ReceivePush(nsIHttpChannel* pushed, nsHostRecord* pushedRec) {
|
||||
uri->GetQuery(query);
|
||||
}
|
||||
|
||||
PRNetAddr tempAddr;
|
||||
if (NS_FAILED(DohDecodeQuery(query, mHost, mType)) ||
|
||||
HostIsIPLiteral(mHost)) { // literal
|
||||
(PR_StringToNetAddr(mHost.get(), &tempAddr) == PR_SUCCESS)) { // literal
|
||||
LOG(("TRR::ReceivePush failed to decode %s\n", mHost.get()));
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -900,12 +900,13 @@ bool nsDNSService::DNSForbiddenByActiveProxy(const nsACString& aHostname,
|
||||
}
|
||||
|
||||
// We should avoid doing DNS when a proxy is in use.
|
||||
NetAddr tempAddr;
|
||||
PRNetAddr tempAddr;
|
||||
if (StaticPrefs::network_proxy_type() ==
|
||||
nsIProtocolProxyService::PROXYCONFIG_MANUAL &&
|
||||
mHasSocksProxy && StaticPrefs::network_proxy_socks_remote_dns()) {
|
||||
// Allow IP lookups through, but nothing else.
|
||||
if (!HostIsIPLiteral(aHostname)) {
|
||||
if (PR_StringToNetAddr(nsCString(aHostname).get(), &tempAddr) !=
|
||||
PR_SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
namespace etld_dafsa {
|
||||
|
||||
@ -314,7 +314,9 @@ nsresult nsEffectiveTLDService::GetBaseDomainInternal(
|
||||
}
|
||||
|
||||
// Check if we're dealing with an IPv4/IPv6 hostname, and return
|
||||
if (mozilla::net::HostIsIPLiteral(aHostname)) {
|
||||
PRNetAddr addr;
|
||||
PRStatus result = PR_StringToNetAddr(aHostname.get(), &addr);
|
||||
if (result == PR_SUCCESS) {
|
||||
// Update the MRU table if in use.
|
||||
if (entry) {
|
||||
entry->Set(TLDCacheEntry{aHostname, ""_ns, NS_ERROR_HOST_IS_IP_ADDRESS});
|
||||
|
@ -937,14 +937,15 @@ already_AddRefed<nsHostRecord> nsHostResolver::InitLoopbackRecord(
|
||||
RefPtr<nsHostRecord> rec = InitRecord(key);
|
||||
|
||||
nsTArray<NetAddr> addresses;
|
||||
NetAddr addr;
|
||||
PRNetAddr prAddr;
|
||||
memset(&prAddr, 0, sizeof(prAddr));
|
||||
if (key.af == PR_AF_INET || key.af == PR_AF_UNSPEC) {
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(addr.InitFromString("127.0.0.1"_ns)));
|
||||
addresses.AppendElement(addr);
|
||||
MOZ_RELEASE_ASSERT(PR_StringToNetAddr("127.0.0.1", &prAddr) == PR_SUCCESS);
|
||||
addresses.AppendElement(NetAddr(&prAddr));
|
||||
}
|
||||
if (key.af == PR_AF_INET6 || key.af == PR_AF_UNSPEC) {
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(addr.InitFromString("::1"_ns)));
|
||||
addresses.AppendElement(addr);
|
||||
MOZ_RELEASE_ASSERT(PR_StringToNetAddr("::1", &prAddr) == PR_SUCCESS);
|
||||
addresses.AppendElement(NetAddr(&prAddr));
|
||||
}
|
||||
|
||||
RefPtr<AddrInfo> ai =
|
||||
@ -989,11 +990,17 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost,
|
||||
}
|
||||
|
||||
// Used to try to parse to an IP address literal.
|
||||
NetAddr tempAddr;
|
||||
if (IS_OTHER_TYPE(type) && (NS_SUCCEEDED(tempAddr.InitFromString(host)))) {
|
||||
PRNetAddr tempAddr;
|
||||
// Unfortunately, PR_StringToNetAddr does not properly initialize
|
||||
// the output buffer in the case of IPv6 input. See bug 223145.
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
if (IS_OTHER_TYPE(type) &&
|
||||
(PR_StringToNetAddr(host.get(), &tempAddr) == PR_SUCCESS)) {
|
||||
// For by-type queries the host cannot be IP literal.
|
||||
return NS_ERROR_UNKNOWN_HOST;
|
||||
}
|
||||
memset(&tempAddr, 0, sizeof(PRNetAddr));
|
||||
|
||||
RefPtr<nsResolveHostCallback> callback(aCallback);
|
||||
// if result is set inside the lock, then we need to issue the
|
||||
@ -1084,7 +1091,8 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost,
|
||||
LOG((" Using cached address for IP Literal [%s].\n", host.get()));
|
||||
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2, METHOD_LITERAL);
|
||||
result = rec;
|
||||
} else if (addrRec && NS_SUCCEEDED(tempAddr.InitFromString(host))) {
|
||||
} else if (addrRec &&
|
||||
PR_StringToNetAddr(host.get(), &tempAddr) == PR_SUCCESS) {
|
||||
// try parsing the host name as an IP address literal to short
|
||||
// circuit full host resolution. (this is necessary on some
|
||||
// platforms like Win9x. see bug 219376 for more details.)
|
||||
@ -1092,7 +1100,8 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost,
|
||||
|
||||
// ok, just copy the result into the host record, and be
|
||||
// done with it! ;-)
|
||||
addrRec->addr = MakeUnique<NetAddr>(tempAddr);
|
||||
addrRec->addr = MakeUnique<NetAddr>();
|
||||
PRNetAddrToNetAddr(&tempAddr, addrRec->addr.get());
|
||||
// put reference to host record on stack...
|
||||
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2, METHOD_LITERAL);
|
||||
result = rec;
|
||||
|
@ -118,10 +118,23 @@ static void AddrToString(NetAddr& netAddr, nsACString& addrStr) {
|
||||
|
||||
static nsresult StringAndPortToNetAddr(nsACString& remoteAddrStr,
|
||||
uint16_t remotePort, NetAddr* netAddr) {
|
||||
if (NS_FAILED(netAddr->InitFromString(remoteAddrStr, remotePort))) {
|
||||
memset(netAddr, 0, sizeof(*netAddr));
|
||||
PRNetAddr remotePRAddr;
|
||||
memset(&remotePRAddr, 0, sizeof(remotePRAddr));
|
||||
PRStatus prRv =
|
||||
PR_StringToNetAddr(remoteAddrStr.BeginReading(), &remotePRAddr);
|
||||
MOZ_ASSERT(prRv == PR_SUCCESS);
|
||||
if (prRv != PR_SUCCESS) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRNetAddrToNetAddr(&remotePRAddr, netAddr);
|
||||
if (netAddr->raw.family == AF_INET6) {
|
||||
netAddr->inet6.port = htons(remotePort);
|
||||
} else {
|
||||
netAddr->inet.port = htons(remotePort);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1819,9 +1819,9 @@ nsresult nsHttpChannel::ProcessSecurityHeaders() {
|
||||
|
||||
// If the channel is not a hostname, but rather an IP, do not process STS
|
||||
// or PKP headers
|
||||
if (HostIsIPLiteral(asciiHost)) {
|
||||
PRNetAddr hostAddr;
|
||||
if (PR_SUCCESS == PR_StringToNetAddr(asciiHost.get(), &hostAddr))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// mSecurityInfo may not always be present, and if it's not then it is okay
|
||||
// to just disregard any security headers since we know nothing about the
|
||||
|
@ -524,12 +524,16 @@ bool nsHttpConnectionInfo::UsingProxy() {
|
||||
}
|
||||
|
||||
bool nsHttpConnectionInfo::HostIsLocalIPLiteral() const {
|
||||
NetAddr netAddr;
|
||||
PRNetAddr prAddr;
|
||||
// If the host/proxy host is not an IP address literal, return false.
|
||||
nsAutoCString host(ProxyHost() ? ProxyHost() : Origin());
|
||||
if (NS_FAILED(netAddr.InitFromString(host))) {
|
||||
if (ProxyHost()) {
|
||||
if (PR_StringToNetAddr(ProxyHost(), &prAddr) != PR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
} else if (PR_StringToNetAddr(Origin(), &prAddr) != PR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
NetAddr netAddr(&prAddr);
|
||||
return netAddr.IsIPAddrLocal();
|
||||
}
|
||||
|
||||
|
@ -51,12 +51,13 @@ StaticRefPtr<nsHttpNTLMAuth> nsHttpNTLMAuth::gSingleton;
|
||||
|
||||
static bool IsNonFqdn(nsIURI* uri) {
|
||||
nsAutoCString host;
|
||||
if (NS_FAILED(uri->GetAsciiHost(host))) {
|
||||
return false;
|
||||
}
|
||||
PRNetAddr addr;
|
||||
|
||||
if (NS_FAILED(uri->GetAsciiHost(host))) return false;
|
||||
|
||||
// return true if host does not contain a dot and is not an ip address
|
||||
return !host.IsEmpty() && !host.Contains('.') && !HostIsIPLiteral(host);
|
||||
return !host.IsEmpty() && !host.Contains('.') &&
|
||||
PR_StringToNetAddr(host.BeginReading(), &addr) != PR_SUCCESS;
|
||||
}
|
||||
|
||||
// Check to see if we should use our generic (internal) NTLM auth module.
|
||||
|
Loading…
x
Reference in New Issue
Block a user