OSDN Git Service

surfaceflinger: Fix range check for getFormat
authorAjay Dudani <adudani@codeaurora.org>
Sun, 3 May 2015 18:44:55 +0000 (11:44 -0700)
committerPatrick Tjin <pattjin@google.com>
Thu, 7 May 2015 20:23:32 +0000 (13:23 -0700)
Fix potential buffer overflow error in getFormat with indices
greater than MAX_HWC_DISPLAYS.

Change-Id: I5e5b69d8d043e900f5e33ca9a62e94ae5f857b68

services/surfaceflinger/DisplayHardware/HWComposer.cpp

index c8b36ec..579b39e 100644 (file)
@@ -461,7 +461,7 @@ sp<Fence> HWComposer::getDisplayFence(int disp) const {
 }
 
 uint32_t HWComposer::getFormat(int disp) const {
-    if (uint32_t(disp)>31 || !mAllocatedDisplayIDs.hasBit(disp)) {
+    if (static_cast<uint32_t>(disp) >= MAX_HWC_DISPLAYS || !mAllocatedDisplayIDs.hasBit(disp)) {
         return HAL_PIXEL_FORMAT_RGBA_8888;
     } else {
         return mDisplayData[disp].format;