diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2015-04-30 14:35:42 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2015-05-01 18:26:52 +0000 |
commit | 0bbf8b213ad96051357e3ad6d6d2808bfa31a59a (patch) | |
tree | 17da4c285aa0b41a76123dbbf2c47b7018d41444 /services/camera/libcameraservice/CameraService.cpp | |
parent | 1de1e25cba872bd4c077c2e394f8ca9c70b65856 (diff) | |
download | frameworks_av-0bbf8b213ad96051357e3ad6d6d2808bfa31a59a.zip frameworks_av-0bbf8b213ad96051357e3ad6d6d2808bfa31a59a.tar.gz frameworks_av-0bbf8b213ad96051357e3ad6d6d2808bfa31a59a.tar.bz2 |
camera2: Fix fuzztesting segfault in connect.
Bug: 20721655
Change-Id: I0d974cad19683a8c86a76dac7f61ac0010bd977a
Diffstat (limited to 'services/camera/libcameraservice/CameraService.cpp')
-rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 8c5c43a..e28464d 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -890,9 +890,12 @@ status_t CameraService::handleEvictionsLocked(const String8& cameraId, int clien if (current != nullptr) { auto clientSp = current->getValue(); if (clientSp.get() != nullptr) { // should never be needed - if (clientSp->getRemote() == remoteCallback) { + if (!clientSp->canCastToApiClient(effectiveApiLevel)) { + ALOGW("CameraService connect called from same client, but with a different" + " API level, evicting prior client..."); + } else if (clientSp->getRemote() == remoteCallback) { ALOGI("CameraService::connect X (PID %d) (second call from same" - "app binder, returning the same client)", clientPid); + " app binder, returning the same client)", clientPid); *client = clientSp; return NO_ERROR; } @@ -1754,6 +1757,11 @@ int CameraService::BasicClient::getClientPid() const { return mClientPid; } +bool CameraService::BasicClient::canCastToApiClient(apiLevel level) const { + // Defaults to API2. + return level == API_2; +} + status_t CameraService::BasicClient::startCameraOps() { int32_t res; // Notify app ops that the camera is not available @@ -1866,6 +1874,10 @@ void CameraService::Client::disconnect() { BasicClient::disconnect(); } +bool CameraService::Client::canCastToApiClient(apiLevel level) const { + return level == API_1; +} + CameraService::Client::OpsCallback::OpsCallback(wp<BasicClient> client): mClient(client) { } |