Bug 950888 - Check for null DNS results before using them. r=mcmanus
authorNicholas Hurley <hurley@todesschaf.org>
Thu, 19 Dec 2013 12:54:47 -0800
changeset 161282 e5def2cce4bcafdd06b5f7f88bcc4f4ab4851b03
parent 161281 5e4acfbcd964dfb5ee2022829e5444fd6f9e6781
child 161283 de90cb114d460f968ad72d36e08f948ac43dcdc2
push id37871
push userhurley@mozilla.com
push dateThu, 19 Dec 2013 20:54:56 +0000
treeherdermozilla-inbound@e5def2cce4bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs950888
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 950888 - Check for null DNS results before using them. r=mcmanus
netwerk/dns/nsHostResolver.cpp
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -967,17 +967,17 @@ public:
     ~ExperimentRunner()
     { }
 
     NS_IMETHOD Run() MOZ_OVERRIDE
     {
         // These are all declared here because compiler warnings about goto.
         DnsQueryFunc dnsQuery;
         TimeStamp startALookup, endALookup, startSRVLookup, endSRVLookup;
-        DNS_RECORDA *aResults, *srvResults;
+        DNS_RECORDA *aResults = nullptr, *srvResults = nullptr;
         DNS_STATUS aStatus, srvStatus;
         int32_t experimentStatus;
         Telemetry::ID deltaKey;
         TimeDuration duration;
         double delta;
         uint32_t timeDelta;
         nsresult rv;
         nsID id;
@@ -1044,28 +1044,36 @@ public:
                                                            &srvResults,
                                                            dnsQuery),
                                     NS_DISPATCH_NORMAL);
 
         WaitForMultipleObjects(2, events, TRUE, INFINITE);
 
         // Ensure we got the expected results
         if (aStatus == DNS_RCODE_NOERROR) {
-            if (aResults->Data.A.IpAddress != 0x7F000001) {
+            if (!aResults) {
+                // Mark this as failed, since we didn't get a result back
+                aStatus = !DNS_RCODE_NOERROR;
+            } else if (aResults->Data.A.IpAddress != 0x7F000001) {
                 correctA = false;
             }
         }
 
         if (srvStatus == DNS_RCODE_NOERROR) {
-            DNS_SRV_DATAA *srvData = &srvResults->Data.Srv;
-            if (_stricmp(srvData->pNameTarget, "success.http2test.mozilla.org") ||
-                srvData->wPort != 443 ||
-                srvData->wPriority != 100 ||
-                srvData->wWeight != 100) {
-                correctSRV = false;
+            if (srvResults) {
+                DNS_SRV_DATAA *srvData = &srvResults->Data.Srv;
+                if (_stricmp(srvData->pNameTarget, "success.http2test.mozilla.org") ||
+                    srvData->wPort != 443 ||
+                    srvData->wPriority != 100 ||
+                    srvData->wWeight != 100) {
+                    correctSRV = false;
+                }
+            } else {
+                // Mark this as failed, since we didn't get a result back
+                srvStatus = !DNS_RCODE_NOERROR;
             }
         }
 
         if (aStatus == DNS_RCODE_NOERROR && srvStatus == DNS_RCODE_NOERROR) {
             experimentStatus = kBothSucceed;
             deltaKey = Telemetry::SRV_EXPERIMENT_SUCCESS_DELTA;
             Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_A_CORRECT, correctA);
             Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_SRV_CORRECT, correctSRV);