diff options
| author | CNSS_WLAN Service <cnssbldsw@qualcomm.com> | 2018-04-12 12:44:09 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-04-12 12:44:09 -0700 |
| commit | 00b4aa51d0ed2869fd43a4ebb63b77832a46898b (patch) | |
| tree | 45d7c5122db521d6bf3930e0862b6171e27787e9 | |
| parent | 03f3c385a0a1e5a87dc01f3148fef52ad70b0d86 (diff) | |
| parent | 5560cdcd0f094e1da18c75849b1b41481f22fa6b (diff) | |
Merge "qcacld-2.0: Fix buffer overread in wma_extscan_cached_results_event_handler" into wlan-cld2.driver.lnx.1.0
| -rw-r--r-- | CORE/SERVICES/WMA/wma.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index 8b45921f9e52..7f9931d54a0b 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -4588,7 +4588,7 @@ static int wma_extscan_cached_results_event_handler(void *handle, struct extscan_cached_scan_results empty_cachelist; wmi_extscan_wlan_descriptor *src_hotlist; wmi_extscan_rssi_info *src_rssi; - int numap, i, moredata, scan_ids_cnt; + int i, moredata, scan_ids_cnt; int buf_len; u_int32_t total_len; bool excess_data = false; @@ -4602,7 +4602,7 @@ static int wma_extscan_cached_results_event_handler(void *handle, if (!pMac->sme.pExtScanIndCb) { WMA_LOGE("%s: Callback not registered", __func__); return -EINVAL; - } + } param_buf = (WMI_EXTSCAN_CACHED_RESULTS_EVENTID_param_tlvs *) cmd_param_info; if (!param_buf) { @@ -4613,39 +4613,16 @@ static int wma_extscan_cached_results_event_handler(void *handle, event = param_buf->fixed_param; src_hotlist = param_buf->bssid_list; src_rssi = param_buf->rssi_list; - numap = event->num_entries_in_page; WMA_LOGI("Total_entries: %u first_entry_index: %u num_entries_in_page: %u", - event->total_entries, event->first_entry_index, numap); - if (!src_hotlist || !src_rssi || !numap) { + event->total_entries, event->first_entry_index, event->num_entries_in_page); + if (!src_hotlist || !src_rssi || !event->num_entries_in_page) { WMA_LOGW("%s: Cached results empty, send 0 results", __func__); goto noresults; - } - - if (event->first_entry_index + - event->num_entries_in_page < event->total_entries) - moredata = 1; - else - moredata = 0; - - dest_cachelist = vos_mem_malloc(sizeof(*dest_cachelist)); - if (!dest_cachelist) { - WMA_LOGE("%s: vos_mem_malloc failed", __func__); - return -ENOMEM; } - vos_mem_zero(dest_cachelist, sizeof(*dest_cachelist)); - dest_cachelist->request_id = event->request_id; - dest_cachelist->more_data = moredata; - - scan_ids_cnt = wma_extscan_find_unique_scan_ids(cmd_param_info); - WMA_LOGI("scan_ids_cnt %d", scan_ids_cnt); - dest_cachelist->num_scan_ids = scan_ids_cnt; - if (event->num_entries_in_page > (WMA_SVC_MSG_MAX_SIZE - sizeof(*event))/sizeof(*src_hotlist)) { WMA_LOGE("%s:excess num_entries_in_page %d in WMI event", __func__, event->num_entries_in_page); - vos_mem_free(dest_cachelist); - VOS_ASSERT(0); return -EINVAL; } else { total_len = sizeof(*event) + @@ -4672,11 +4649,28 @@ static int wma_extscan_cached_results_event_handler(void *handle, } if (excess_data) { WMA_LOGE("%s:excess data in WMI event", __func__); - vos_mem_free(dest_cachelist); - VOS_ASSERT(0); return -EINVAL; } + if (event->first_entry_index + + event->num_entries_in_page < event->total_entries) + moredata = 1; + else + moredata = 0; + + dest_cachelist = vos_mem_malloc(sizeof(*dest_cachelist)); + if (!dest_cachelist) { + WMA_LOGE("%s: vos_mem_malloc failed", __func__); + return -ENOMEM; + } + vos_mem_zero(dest_cachelist, sizeof(*dest_cachelist)); + dest_cachelist->request_id = event->request_id; + dest_cachelist->more_data = moredata; + + scan_ids_cnt = wma_extscan_find_unique_scan_ids(cmd_param_info); + WMA_LOGD("scan_ids_cnt %d", scan_ids_cnt); + dest_cachelist->num_scan_ids = scan_ids_cnt; + buf_len = sizeof(*dest_result) * scan_ids_cnt; dest_cachelist->result = vos_mem_malloc(buf_len); if (!dest_cachelist->result) { |
