diff options
author | 2021-07-30 14:37:10 -0700 | |
---|---|---|
committer | 2021-07-30 14:45:24 -0700 | |
commit | 40b736e02e45d743821a51d24ed9580bbbffc71e (patch) | |
tree | 1996d88d16682fe31453e4ba46ad65985343deca /libs/binder/RpcSession.cpp | |
parent | ac9df9ed1fe8dcf6243bc57f395ecb13ab49eaaa (diff) |
libbinder: disallow upgrade of explicit version
If we have explicitly set a version, we want to test that that version
is actually being used, and we don't want the other side of the
connection to decide to artificially upgrade the version.
Bug: 182938972
Test: binderRpcTest (w/ Cls to simulate versions added)
Change-Id: Id784672100c0445d5ea77c4fc3b063daa5efa0b0
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r-- | libs/binder/RpcSession.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index 90ce4d6d3f..254b99c29a 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -87,6 +87,12 @@ bool RpcSession::setProtocolVersion(uint32_t version) { } std::lock_guard<std::mutex> _l(mMutex); + if (mProtocolVersion && version > *mProtocolVersion) { + ALOGE("Cannot upgrade explicitly capped protocol version %u to newer version %u", + *mProtocolVersion, version); + return false; + } + mProtocolVersion = version; return true; } |