OSDN Git Service

DO NOT MERGE Fix use-after-free of mClient member DnsProxyListener::GetHostByNameHand...
authorMichal Karpinski <mkarpinski@google.com>
Mon, 14 Nov 2016 09:29:03 +0000 (09:29 +0000)
committerMichal Karpinski <mkarpinski@google.com>
Fri, 2 Dec 2016 17:26:57 +0000 (17:26 +0000)
Found by ASan.

Test: Flash ASan build, boot up and verify that system/netd does not
crash with AddressSanitizer induced errors.

Bug: 32810214
Bug: 29748723

(cherry picked from commit f8bb7ecc72e7a18ff5528613f79316634e8f6885)

Change-Id: I8814756588b2bb4c78583a829e08d33305797642

server/DnsProxyListener.cpp

index 861f9c1..aea5bdc 100644 (file)
@@ -428,7 +428,6 @@ void DnsProxyListener::GetHostByNameHandler::run() {
     if (!success) {
         ALOGW("GetHostByNameHandler: Error writing DNS result to client\n");
     }
-    mClient->decRef();
 
     if (mNetdEventListener != nullptr) {
         std::vector<String16> ip_addrs;
@@ -467,6 +466,8 @@ void DnsProxyListener::GetHostByNameHandler::run() {
                 break;
         }
     }
+
+    mClient->decRef();
 }