From a7c45f4f5aa275628c2ad6e72ef12bed84535d0e Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 22 Mar 2022 15:25:54 -0700 Subject: DO NOT MERGE: SurfaceControl: Ensure unused fields are zeroed Otherwise we could leak uninitialized memory to an untrusted process. Bug: 214999987 Test: Existing tests pass Change-Id: I87993fbb920b3af938a311e6afc15383d571823a (cherry picked from commit c2cf02c17af0d7e5f58b8a17ecb9cfcc91a4d2eb) --- libs/gui/SurfaceControl.cpp | 1 + libs/gui/include/gui/SurfaceControl.h | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 6529a4e51c..f93b799757 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -70,6 +70,7 @@ SurfaceControl::SurfaceControl(const sp& other) { mLayerId = other->mLayerId; mWidth = other->mWidth; mHeight = other->mHeight; + mFormat = other->mFormat; mCreateFlags = other->mCreateFlags; } diff --git a/libs/gui/include/gui/SurfaceControl.h b/libs/gui/include/gui/SurfaceControl.h index 9ee4636ae1..ed14ec6744 100644 --- a/libs/gui/include/gui/SurfaceControl.h +++ b/libs/gui/include/gui/SurfaceControl.h @@ -118,12 +118,13 @@ private: mutable sp mSurfaceData; mutable sp mBbq; mutable sp mBbqChild; - int32_t mLayerId; - uint32_t mTransformHint; - uint32_t mWidth; - uint32_t mHeight; - PixelFormat mFormat; - uint32_t mCreateFlags; + + int32_t mLayerId = 0; + uint32_t mTransformHint = 0; + uint32_t mWidth = 0; + uint32_t mHeight = 0; + PixelFormat mFormat = PIXEL_FORMAT_NONE; + uint32_t mCreateFlags = 0; }; }; // namespace android -- cgit v1.2.3-59-g8ed1b