Merge "ipc: HwBinders: Fix potential out of bound access"
diff --git a/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp b/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
index 4bd504e..aa640c4 100644
--- a/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
+++ b/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
@@ -906,6 +906,18 @@
ALOGV("%s : session_id = %d\n", __func__, session_id);
struct agm_event_reg_cfg *evt_reg_cfg_local;
int32_t ret = 0;
+
+ if (evt_reg_cfg.size() != 1) {
+ ALOGE("%s evt_reg_cfg needs to be of size 1\n", __func__);
+ return -EINVAL;
+ }
+
+ if (evt_reg_cfg.data()->event_config_payload.size() !=
+ evt_reg_cfg.data()->event_config_payload_size) {
+ ALOGE("%s: event_config_payload_size value mismatch\n", __func__);
+ return -EINVAL;
+ }
+
evt_reg_cfg_local = (struct agm_event_reg_cfg*)
calloc(1,(sizeof(struct agm_event_reg_cfg) +
(evt_reg_cfg.data()->event_config_payload_size)*sizeof(uint8_t)));