Skip to content

Commit

Permalink
hwc2: Validate bounds check for input parcel.
Browse files Browse the repository at this point in the history
CRs-Fixed: 2394384
Change-Id: Iba254b3579cd2c258c3cf80fe234a0de7d75e599
  • Loading branch information
Ravikanth Tuniki committed Feb 28, 2019
1 parent 8fd9eb0 commit 10cb748
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions sdm/libs/hwc2/hwc_session_services.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -116,7 +116,8 @@ Return<void> HWCSession::isDisplayConnected(IDisplayConfig::DisplayType dpy,
}

int32_t HWCSession::SetSecondaryDisplayStatus(int disp_id, HWCDisplay::DisplayStatus status) {
if (disp_id < 0) {
if (disp_id < HWC_DISPLAY_PRIMARY || disp_id >= HWC_NUM_DISPLAY_TYPES) {
DLOGE("Invalid display = %d", disp_id);
return -EINVAL;
}

Expand Down Expand Up @@ -163,7 +164,8 @@ Return<int32_t> HWCSession::configureDynRefeshRate(IDisplayConfig::DisplayDynRef
}

int32_t HWCSession::GetConfigCount(int disp_id, uint32_t *count) {
if (disp_id < 0) {
if (disp_id < HWC_DISPLAY_PRIMARY || disp_id >= HWC_NUM_DISPLAY_TYPES) {
DLOGE("Invalid display = %d", disp_id);
return -EINVAL;
}

Expand All @@ -187,7 +189,8 @@ Return<void> HWCSession::getConfigCount(IDisplayConfig::DisplayType dpy,
}

int32_t HWCSession::GetActiveConfigIndex(int disp_id, uint32_t *config) {
if (disp_id < 0) {
if (disp_id < HWC_DISPLAY_PRIMARY || disp_id >= HWC_NUM_DISPLAY_TYPES) {
DLOGE("Invalid display = %d", disp_id);
return -EINVAL;
}

Expand All @@ -211,7 +214,8 @@ Return<void> HWCSession::getActiveConfig(IDisplayConfig::DisplayType dpy,
}

int32_t HWCSession::SetActiveConfigIndex(int disp_id, uint32_t config) {
if (disp_id < 0) {
if (disp_id < HWC_DISPLAY_PRIMARY || disp_id >= HWC_NUM_DISPLAY_TYPES) {
DLOGE("Invalid display = %d", disp_id);
return -EINVAL;
}

Expand Down Expand Up @@ -300,7 +304,8 @@ Return<void> HWCSession::getPanelBrightness(getPanelBrightness_cb _hidl_cb) {
int32_t HWCSession::MinHdcpEncryptionLevelChanged(int disp_id, uint32_t min_enc_level) {
DLOGI("Display %d", disp_id);

if (disp_id < 0) {
if (disp_id < HWC_DISPLAY_PRIMARY || disp_id >= HWC_NUM_DISPLAY_TYPES) {
DLOGE("Invalid display = %d", disp_id);
return -EINVAL;
}

Expand Down Expand Up @@ -329,7 +334,8 @@ Return<int32_t> HWCSession::refreshScreen() {
}

int32_t HWCSession::ControlPartialUpdate(int disp_id, bool enable) {
if (disp_id < 0) {
if (disp_id < HWC_DISPLAY_PRIMARY || disp_id >= HWC_NUM_DISPLAY_TYPES) {
DLOGE("Invalid display = %d", disp_id);
return -EINVAL;
}

Expand Down

0 comments on commit 10cb748

Please sign in to comment.