diff options
author | ttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 17:39:14 +0000 |
---|---|---|
committer | ttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 17:39:14 +0000 |
commit | b6e66d509d9c8c7ae39f1928897331ba4b3dd585 (patch) | |
tree | 7640211db74154724f0f6cc916a675e5471c5a68 /chrome/browser/net/dns_probe_service.cc | |
parent | c5d6687ecce69465775e01ba7f8200201e23f160 (diff) | |
download | chromium_src-b6e66d509d9c8c7ae39f1928897331ba4b3dd585.zip chromium_src-b6e66d509d9c8c7ae39f1928897331ba4b3dd585.tar.gz chromium_src-b6e66d509d9c8c7ae39f1928897331ba4b3dd585.tar.bz2 |
DnsProbeService: Don't create job with invalid config
A DnsProbeJob with a DnsClient with an invalid config will explode
spectacularly (segfault) when started. In DnsProbeService, don't create jobs
with invalid configs, and return PROBE_UNKNOWN if we couldn't create one or
both jobs.
BUG=156415,162506
Review URL: https://chromiumcodereview.appspot.com/11413163
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/dns_probe_service.cc')
-rw-r--r-- | chrome/browser/net/dns_probe_service.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/chrome/browser/net/dns_probe_service.cc b/chrome/browser/net/dns_probe_service.cc index 3a14bbc..99f9e46 100644 --- a/chrome/browser/net/dns_probe_service.cc +++ b/chrome/browser/net/dns_probe_service.cc @@ -105,6 +105,16 @@ void DnsProbeService::StartProbes() { system_job_ = CreateSystemProbeJob(job_callback); public_job_ = CreatePublicProbeJob(job_callback); + // If we can't create one or both jobs, fail the probe immediately. + if (!system_job_.get() || !public_job_.get()) { + system_job_.reset(); + public_job_.reset(); + state_ = STATE_RESULTS_CACHED; + result_ = PROBE_UNKNOWN; + CallCallbacks(); + return; + } + state_ = STATE_PROBE_RUNNING; probe_start_time_ = base::Time::Now(); } @@ -165,6 +175,9 @@ void DnsProbeService::CallCallbacks() { scoped_ptr<DnsProbeJob> DnsProbeService::CreateProbeJob( const DnsConfig& dns_config, const DnsProbeJob::CallbackType& job_callback) { + if (!dns_config.IsValid()) + return scoped_ptr<DnsProbeJob>(NULL); + scoped_ptr<DnsClient> dns_client(DnsClient::CreateClient(NULL)); dns_client->SetConfig(dns_config); return DnsProbeJob::CreateJob(dns_client.Pass(), job_callback, NULL); @@ -192,7 +205,6 @@ void DnsProbeService::OnProbeJobComplete(DnsProbeJob* job, } void DnsProbeService::GetSystemDnsConfig(DnsConfig* config) { - // TODO(ttuttle): Make sure we handle missing config properly NetworkChangeNotifier::GetDnsConfig(config); } |