From 4e3e30c2d5a2a6f7dc4ee8696b1ac2a52dffd5dc Mon Sep 17 00:00:00 2001 From: Ajay Dudani Date: Sun, 3 May 2015 11:44:55 -0700 Subject: [PATCH] surfaceflinger: Fix range check for getFormat Fix potential buffer overflow error in getFormat with indices greater than MAX_HWC_DISPLAYS. Change-Id: I5e5b69d8d043e900f5e33ca9a62e94ae5f857b68 --- services/surfaceflinger/DisplayHardware/HWComposer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index c8b36ec03..579b39eb2 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -461,7 +461,7 @@ sp HWComposer::getDisplayFence(int disp) const { } uint32_t HWComposer::getFormat(int disp) const { - if (uint32_t(disp)>31 || !mAllocatedDisplayIDs.hasBit(disp)) { + if (static_cast(disp) >= MAX_HWC_DISPLAYS || !mAllocatedDisplayIDs.hasBit(disp)) { return HAL_PIXEL_FORMAT_RGBA_8888; } else { return mDisplayData[disp].format;