summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-10-22 15:38:00 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-22 15:38:00 -0700
commitba0b9cca697a84947c08983338ce4e7f30920fd8 (patch)
tree78e8adf33aa9336f3d1c946a135ae9223da09747
parent7ee4aba226b85236b8b21d4311cc18471c72b936 (diff)
parentef36f2a84cb8478b0baa299d980922ce7824c0b3 (diff)
downloadframeworks_native-ba0b9cca697a84947c08983338ce4e7f30920fd8.zip
frameworks_native-ba0b9cca697a84947c08983338ce4e7f30920fd8.tar.gz
frameworks_native-ba0b9cca697a84947c08983338ce4e7f30920fd8.tar.bz2
am ef36f2a8: am d17e3b5f: prevent a client from crashing surfaceflinger
* commit 'ef36f2a84cb8478b0baa299d980922ce7824c0b3': prevent a client from crashing surfaceflinger
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 38e02f1..26e9c60 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1681,8 +1681,23 @@ void SurfaceFlinger::setTransactionState(
count = state.size();
for (size_t i=0 ; i<count ; i++) {
const ComposerState& s(state[i]);
- sp<Client> client( static_cast<Client *>(s.client.get()) );
- transactionFlags |= setClientStateLocked(client, s.state);
+ // Here we need to check that the interface we're given is indeed
+ // one of our own. A malicious client could give us a NULL
+ // IInterface, or one of its own or even one of our own but a
+ // different type. All these situations would cause us to crash.
+ //
+ // NOTE: it would be better to use RTTI as we could directly check
+ // that we have a Client*. however, RTTI is disabled in Android.
+ if (s.client != NULL) {
+ sp<IBinder> binder = s.client->asBinder();
+ if (binder != NULL) {
+ String16 desc(binder->getInterfaceDescriptor());
+ if (desc == ISurfaceComposerClient::descriptor) {
+ sp<Client> client( static_cast<Client *>(s.client.get()) );
+ transactionFlags |= setClientStateLocked(client, s.state);
+ }
+ }
+ }
}
if (transactionFlags) {