libbinder: RPC skip init on /dev/null
This started breaking the fuzzer, since we can't do a socket operation
on /dev/null.
Bug: N/A # yet!
Test: fuzzer no longer crashes
Change-Id: I881f63b85108ff488cb5798b1f0b96629b592329
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index 931a876..4f55eef 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -100,7 +100,7 @@
return false;
}
- return addOutgoingConnection(std::move(serverFd));
+ return addOutgoingConnection(std::move(serverFd), false);
}
sp<IBinder> RpcSession::getRootObject() {
@@ -432,7 +432,7 @@
LOG_ALWAYS_FATAL_IF(!ownershipTransferred);
return true;
} else {
- return addOutgoingConnection(std::move(serverFd));
+ return addOutgoingConnection(std::move(serverFd), true);
}
}
@@ -440,7 +440,7 @@
return false;
}
-bool RpcSession::addOutgoingConnection(unique_fd fd) {
+bool RpcSession::addOutgoingConnection(unique_fd fd, bool init) {
sp<RpcConnection> connection = sp<RpcConnection>::make();
{
std::lock_guard<std::mutex> _l(mMutex);
@@ -458,7 +458,10 @@
mOutgoingConnections.push_back(connection);
}
- status_t status = mState->sendConnectionInit(connection, sp<RpcSession>::fromExisting(this));
+ status_t status = OK;
+ if (init) {
+ mState->sendConnectionInit(connection, sp<RpcSession>::fromExisting(this));
+ }
{
std::lock_guard<std::mutex> _l(mMutex);