displayConfig: Add size validation for client input parameters
CRs-Fixed: 3259301
Change-Id: Ie6f1a273f69a7cb4eaff0b5c1016571c49850198
diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp
index c8f64dc..d9d88c0 100644
--- a/services/config/src/device_impl.cpp
+++ b/services/config/src/device_impl.cpp
@@ -233,6 +233,10 @@
bool connected = false;
ByteStream output_params;
+ if (input_params.size() != sizeof(DisplayType)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
dpy = reinterpret_cast<const DisplayType*>(data);
int32_t error = intf_->IsDisplayConnected(*dpy, &connected);
@@ -246,6 +250,11 @@
perform_cb _hidl_cb) {
const struct StatusParams *display_status;
const uint8_t *data = input_params.data();
+
+ if (input_params.size() != sizeof(StatusParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
display_status = reinterpret_cast<const StatusParams*>(data);
int32_t error = intf_->SetDisplayStatus(display_status->dpy,
display_status->status);
@@ -256,6 +265,11 @@
perform_cb _hidl_cb) {
const struct DynRefreshRateParams *dyn_refresh_data;
const uint8_t *data = input_params.data();
+
+ if (input_params.size() != sizeof(DynRefreshRateParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
dyn_refresh_data = reinterpret_cast<const DynRefreshRateParams*>(data);
int32_t error = intf_->ConfigureDynRefreshRate(dyn_refresh_data->op,
dyn_refresh_data->refresh_rate);
@@ -273,6 +287,10 @@
return;
}
+ if (input_params.size() != sizeof(DisplayType)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
dpy = reinterpret_cast<const DisplayType*>(data);
int32_t error = intf_->GetConfigCount(*dpy, &count);
@@ -287,6 +305,10 @@
uint32_t config = 0;
ByteStream output_params;
+ if (input_params.size() != sizeof(DisplayType)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
dpy = reinterpret_cast<const DisplayType*>(data);
int32_t error = intf_->GetActiveConfig(*dpy, &config);
@@ -299,6 +321,10 @@
perform_cb _hidl_cb) {
const struct ConfigParams *set_active_cfg_data;
+ if (input_params.size() != sizeof(ConfigParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
set_active_cfg_data = reinterpret_cast<const ConfigParams*>(data);
int32_t error = intf_->SetActiveConfig(set_active_cfg_data->dpy,
@@ -313,6 +339,10 @@
ByteStream output_params;
int32_t error = -EINVAL;
+ if (input_params.size() != sizeof(AttributesParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
get_disp_attr_data = reinterpret_cast<const AttributesParams*>(data);
error = intf_->GetDisplayAttributes(get_disp_attr_data->config_index, get_disp_attr_data->dpy,
@@ -327,6 +357,10 @@
const uint32_t *level;
int32_t error = 0;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
level = reinterpret_cast<const uint32_t*>(data);
error = intf_->SetPanelBrightness(*level);
@@ -352,6 +386,10 @@
const struct MinHdcpEncLevelChangedParams *min_hdcp_enc_level_data;
int32_t error = 0;
+ if (input_params.size() != sizeof(MinHdcpEncLevelChangedParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
min_hdcp_enc_level_data = reinterpret_cast<const MinHdcpEncLevelChangedParams*>(data);
error = intf_->MinHdcpEncryptionLevelChanged(min_hdcp_enc_level_data->dpy,
@@ -370,6 +408,10 @@
const struct PartialUpdateParams *partial_update_data;
int32_t error = 0;
+ if (input_params.size() != sizeof(PartialUpdateParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
partial_update_data = reinterpret_cast<const PartialUpdateParams*>(data);
error = intf_->ControlPartialUpdate(partial_update_data->dpy, partial_update_data->enable);
@@ -382,6 +424,10 @@
const bool *on;
int32_t error = 0;
+ if (input_params.size() != sizeof(bool)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
on = reinterpret_cast<const bool*>(data);
error = intf_->ToggleScreenUpdate(on);
@@ -393,6 +439,10 @@
perform_cb _hidl_cb) {
const uint32_t *timeout_value;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
timeout_value = reinterpret_cast<const uint32_t*>(data);
int32_t error = intf_->SetIdleTimeout(*timeout_value);
@@ -408,6 +458,10 @@
int32_t *data_output;
int32_t error = -EINVAL;
+ if (input_params.size() != sizeof(DisplayType)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
dpy = reinterpret_cast<const DisplayType*>(data);
error = intf_->GetHDRCapabilities(*dpy, &hdr_caps);
@@ -437,6 +491,10 @@
perform_cb _hidl_cb) {
const uint32_t *launch_status_data;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
launch_status_data = reinterpret_cast<const uint32_t*>(data);
@@ -449,6 +507,10 @@
perform_cb _hidl_cb) {
const CameraSmoothInfo *camera_info;
+ if (input_params.size() != sizeof(CameraSmoothInfo)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
camera_info = reinterpret_cast<const CameraSmoothInfo*>(data);
int32_t error = intf_->SetCameraSmoothInfo(camera_info->op, camera_info->fps);
@@ -459,6 +521,10 @@
perform_cb _hidl_cb) {
const bool *enable;
+ if (input_params.size() != sizeof(bool)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
enable = reinterpret_cast<const bool*>(data);
@@ -482,6 +548,10 @@
perform_cb _hidl_cb) {
const struct AnimationParams *display_animating_data;
+ if (input_params.size() != sizeof(AnimationParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
display_animating_data = reinterpret_cast<const AnimationParams*>(data);
int32_t error = intf_->SetDisplayAnimating(display_animating_data->display_id,
@@ -494,6 +564,10 @@
perform_cb _hidl_cb) {
const struct IdlePcParams *idle_pc_data;
+ if (input_params.size() != sizeof(IdlePcParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
idle_pc_data = reinterpret_cast<const IdlePcParams*>(data);
int32_t error = intf_->ControlIdlePowerCollapse(idle_pc_data->enable, idle_pc_data->synchronous);
@@ -515,6 +589,10 @@
perform_cb _hidl_cb) {
const struct DppsAdRoiParams *ad_roi_data;
+ if (input_params.size() != sizeof(DppsAdRoiParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
ad_roi_data = reinterpret_cast<const DppsAdRoiParams*>(data);
@@ -540,6 +618,10 @@
perform_cb _hidl_cb) {
const struct PowerModeParams *set_power_mode_data;
+ if (input_params.size() != sizeof(PowerModeParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
set_power_mode_data = reinterpret_cast<const PowerModeParams*>(data);
int32_t error = intf_->SetPowerMode(set_power_mode_data->disp_id,
@@ -550,6 +632,10 @@
void DeviceImpl::DeviceClientContext::ParseIsPowerModeOverrideSupported(
const ByteStream &input_params,
perform_cb _hidl_cb) {
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
bool supported = false;
@@ -563,6 +649,10 @@
void DeviceImpl::DeviceClientContext::ParseIsHdrSupported(const ByteStream &input_params,
perform_cb _hidl_cb) {
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
bool supported = false;
@@ -576,6 +666,10 @@
void DeviceImpl::DeviceClientContext::ParseIsWcgSupported(const ByteStream &input_params,
perform_cb _hidl_cb) {
+ if (input_params.size() != sizeof(int32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
const int32_t *disp_id = reinterpret_cast<const int32_t*>(data);
bool supported = false;
@@ -591,6 +685,10 @@
perform_cb _hidl_cb) {
const struct LayerMaskParams *layer_mask_data;
+ if (input_params.size() != sizeof(LayerMaskParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
layer_mask_data = reinterpret_cast<const LayerMaskParams*>(data);
int32_t error = intf_->SetLayerAsMask(layer_mask_data->disp_id, layer_mask_data->layer_id);
@@ -605,6 +703,7 @@
const uint8_t *data = input_params.data();
const char *name = reinterpret_cast<const char *>(data);
+ name[input_params.size()-1] = '\0';
std::string prop_name(name);
int32_t error = intf_->GetDebugProperty(prop_name, &value);
value += '\0';
@@ -630,6 +729,10 @@
perform_cb _hidl_cb) {
const struct PanelLumAttrParams *panel_lum_attr_data;
+ if (input_params.size() != sizeof(PanelLumAttrParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
panel_lum_attr_data = reinterpret_cast<const PanelLumAttrParams*>(data);
int32_t error = intf_->SetPanelLuminanceAttributes(panel_lum_attr_data->disp_id,
@@ -645,6 +748,10 @@
bool is_builtin = false;
ByteStream output_params;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
disp_id = reinterpret_cast<const uint32_t*>(data);
int32_t error = intf_->IsBuiltInDisplay(*disp_id, &is_builtin);
@@ -660,6 +767,10 @@
perform_cb _hidl_cb) {
const struct CwbBufferParams *cwb_buffer_data;
+ if (input_params.size() != sizeof(CwbBufferParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
cwb_buffer_data = reinterpret_cast<const CwbBufferParams*>(data);
hidl_handle buffer = input_handles[0];
@@ -682,6 +793,10 @@
std::vector<uint64_t> bit_clks;
uint64_t *bit_clks_data;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
disp_id = reinterpret_cast<const uint32_t*>(data);
int32_t error = intf_->GetSupportedDSIBitClks(*disp_id, &bit_clks);
@@ -705,6 +820,10 @@
uint64_t bit_clk = 0;
ByteStream output_params;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
disp_id = reinterpret_cast<const uint32_t*>(data);
int32_t error = intf_->GetDSIClk(*disp_id, &bit_clk);
@@ -718,6 +837,10 @@
perform_cb _hidl_cb) {
const struct DsiClkParams *set_dsi_clk_data;
+ if (input_params.size() != sizeof(DsiClkParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
set_dsi_clk_data = reinterpret_cast<const DsiClkParams*>(data);
int32_t error = intf_->SetDSIClk(set_dsi_clk_data->disp_id, set_dsi_clk_data->bit_clk);
@@ -728,6 +851,10 @@
perform_cb _hidl_cb) {
const struct QsyncModeParams *set_qsync_mode_data;
+ if (input_params.size() != sizeof(QsyncModeParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
set_qsync_mode_data = reinterpret_cast<const QsyncModeParams*>(data);
int32_t error = intf_->SetQsyncMode(set_qsync_mode_data->disp_id, set_qsync_mode_data->mode);
@@ -740,6 +867,10 @@
bool is_smart = false;
ByteStream output_params;
+ if (input_params.size() != sizeof(SmartPanelCfgParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
smart_panel_cfg_data = reinterpret_cast<const SmartPanelCfgParams*>(data);
int32_t error = intf_->IsSmartPanelConfig(smart_panel_cfg_data->disp_id,
@@ -764,6 +895,10 @@
perform_cb _hidl_cb) {
const struct VdsParams *vds_input_data;
+ if (input_params.size() != sizeof(VdsParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
vds_input_data = reinterpret_cast<const VdsParams*>(data);
@@ -779,6 +914,10 @@
bool supported = false;
ByteStream output_params;
+ if (input_params.size() != sizeof(RotatorFormatParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
input_data = reinterpret_cast<const RotatorFormatParams*>(data);
int32_t error = intf_->IsRotatorSupportedFormat(input_data->hal_format, input_data->ubwc,
@@ -794,6 +933,10 @@
perform_cb _hidl_cb) {
const bool *enable;
+ if (input_params.size() != sizeof(bool)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
enable = reinterpret_cast<const bool*>(data);
@@ -807,6 +950,10 @@
perform_cb _hidl_cb) {
const bool *enable;
+ if (input_params.size() != sizeof(bool)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
enable = reinterpret_cast<const bool*>(data);
@@ -820,6 +967,10 @@
const struct TUIEventParams *input_data =
reinterpret_cast<const TUIEventParams*>(input_params.data());
+ if (input_params.size() != sizeof(TUIEventParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
int32_t error = intf_->SendTUIEvent(input_data->dpy, input_data->tui_event_type);
_hidl_cb(error, {}, {});
@@ -851,6 +1002,10 @@
uint32_t disp_hw_id = 0;
ByteStream output_params;
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
int32_t error = intf_->GetDisplayHwId(*disp_id, &disp_hw_id);
@@ -864,6 +1019,9 @@
ByteStream output_params;
std::vector<uint32_t> refresh_rates;
+ if (input_params.size() != sizeof(DisplayType)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
const uint8_t *data = input_params.data();
const DisplayType *dpy = reinterpret_cast<const DisplayType *>(data);
int32_t error = intf_->GetSupportedDisplayRefreshRates(*dpy, &refresh_rates);
@@ -885,6 +1043,11 @@
void DeviceImpl::DeviceClientContext::ParseIsRCSupported(const ByteStream &input_params,
perform_cb _hidl_cb) {
const uint8_t *data = input_params.data();
+
+ if (input_params.size() != sizeof(uint32_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
bool supported = false;
int32_t error = intf_->IsRCSupported(*disp_id, &supported);
@@ -902,6 +1065,11 @@
}
const struct SupportedModesParams *supported_modes_data;
+
+ if (input_params.size() != sizeof(SupportedModesParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
bool supported = false;
ByteStream output_params;
@@ -915,6 +1083,10 @@
void DeviceImpl::DeviceClientContext::ParseGetDisplayType(const ByteStream &input_params,
perform_cb _hidl_cb) {
+ if (input_params.size() != sizeof(uint64_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
const uint64_t *physical_disp_id = reinterpret_cast<const uint64_t*>(data);
DisplayType disp_type = DisplayConfig::DisplayType::kInvalid;
@@ -932,6 +1104,10 @@
void DeviceImpl::DeviceClientContext::ParseGetDisplayTileCount(const ByteStream &input_params,
perform_cb _hidl_cb) {
+ if (input_params.size() != sizeof(uint64_t)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint64_t *data = reinterpret_cast<const uint64_t*>(input_params.data());
uint64_t physical_disp_id = data ? *data : 0;
uint32_t num_tiles[2] = {0, 0};
@@ -948,6 +1124,10 @@
perform_cb _hidl_cb) {
struct PowerModeTiledParams set_power_mode_tiled_data = {};
+ if (input_params.size() != sizeof(PowerModeTiledParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
if (data) {
set_power_mode_tiled_data = *reinterpret_cast<const PowerModeTiledParams*>(data);
@@ -963,6 +1143,10 @@
perform_cb _hidl_cb) {
struct PanelBrightnessTiledParams set_panel_brightness_tiled_data = {};
+ if (input_params.size() != sizeof(PanelBrightnessTiledParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
if (data) {
set_panel_brightness_tiled_data = *reinterpret_cast<const PanelBrightnessTiledParams*>(data);
@@ -978,6 +1162,10 @@
perform_cb _hidl_cb) {
struct WiderModePrefParams set_wider_mode_pref_data = {};
+ if (input_params.size() != sizeof(WiderModePrefParams)) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
const uint8_t *data = input_params.data();
if (data) {
set_wider_mode_pref_data = *reinterpret_cast<const WiderModePrefParams*>(data);