diff options
author | 2023-05-11 23:23:26 +0000 | |
---|---|---|
committer | 2023-05-12 22:31:29 +0000 | |
commit | ca3f638f9628fddd0f713c932cca8818c1898890 (patch) | |
tree | 8e8c338cf250af1c773e526afd356f3236c0411f /libs/binder/RpcState.cpp | |
parent | 71ea90d35134e972978f92add142857a10104552 (diff) |
libbinder: RpcServer protocol version error
Return an error if you set an invalid protocol
version on an RpcServer.
Previously, this would cause errors later down
the line.
Bug: 278946301
Test: binderRpcTest
Change-Id: Id496f1d39b2a32ce775e585f7690ae59503dc3aa
Diffstat (limited to 'libs/binder/RpcState.cpp')
-rw-r--r-- | libs/binder/RpcState.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 03fa69973d..ff35f5f35c 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -398,6 +398,18 @@ status_t RpcState::rpcRec( return OK; } +bool RpcState::validateProtocolVersion(uint32_t version) { + if (version >= RPC_WIRE_PROTOCOL_VERSION_NEXT && + version != RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) { + ALOGE("Cannot use RPC binder protocol version %u which is unknown (current protocol " + "version " + "is %u).", + version, RPC_WIRE_PROTOCOL_VERSION); + return false; + } + return true; +} + status_t RpcState::readNewSessionResponse(const sp<RpcSession::RpcConnection>& connection, const sp<RpcSession>& session, uint32_t* version) { RpcNewSessionResponse response; |