From b6e66d509d9c8c7ae39f1928897331ba4b3dd585 Mon Sep 17 00:00:00 2001 From: "ttuttle@chromium.org" Date: Tue, 27 Nov 2012 17:39:14 +0000 Subject: 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 --- chrome/browser/net/dns_probe_service.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'chrome/browser/net/dns_probe_service.cc') 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 DnsProbeService::CreateProbeJob( const DnsConfig& dns_config, const DnsProbeJob::CallbackType& job_callback) { + if (!dns_config.IsValid()) + return scoped_ptr(NULL); + scoped_ptr 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); } -- cgit v1.1