summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandrasekaran, Manishekar <cmshekar@qti.qualcomm.com>2016-04-19 19:25:22 +0530
committerAnjaneedevi Kapparapu <akappa@codeaurora.org>2016-04-22 16:37:17 +0530
commit26301465dde601b9609e39a7315ee516a275c06f (patch)
tree3bf141bb5535ec907175ebba4159806498144f0d
parent472b196004c020f50f7321d927098e2034ebdcd4 (diff)
qcacld-2.0: Check the return value of snprintf during STA info collection
Check the return value of snprintf during STA info collection to identify any insufficient buffer condition. Change-Id: I4edd7c8e094c40f41fe2ec019a72ef9e82ac903f CRs-Fixed: 1005996
-rw-r--r--CORE/HDD/src/wlan_hdd_hostapd.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index 36179db68851..1422ceb7969e 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -5732,7 +5732,7 @@ static int iw_softap_version(struct net_device *dev,
return ret;
}
-static VOS_STATUS
+static int
hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
{
v_U8_t i;
@@ -5755,7 +5755,11 @@ hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
if (0 != ret)
return ret;
- len = scnprintf(pBuf, buf_len, sta_info_header);
+ len = snprintf(pBuf, buf_len, sta_info_header);
+ if (len >= buf_len) {
+ hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
+ return -E2BIG;
+ }
pBuf += len;
buf_len -= len;
@@ -5773,6 +5777,10 @@ hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
pAdapter->aStaInfo[i].macAddrSTA.bytes[3],
pAdapter->aStaInfo[i].macAddrSTA.bytes[4],
pAdapter->aStaInfo[i].macAddrSTA.bytes[5]);
+ if (len >= buf_len) {
+ hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
+ return -E2BIG;
+ }
pBuf += len;
buf_len -= len;
}
@@ -5782,7 +5790,7 @@ hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
}
}
EXIT();
- return VOS_STATUS_SUCCESS;
+ return 0;
}
static int __iw_softap_get_sta_info(struct net_device *dev,
@@ -5791,7 +5799,6 @@ static int __iw_softap_get_sta_info(struct net_device *dev,
char *extra)
{
hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
- VOS_STATUS status;
hdd_context_t *hdd_ctx;
int ret;
@@ -5802,10 +5809,10 @@ static int __iw_softap_get_sta_info(struct net_device *dev,
if (0 != ret)
return ret;
- status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
- if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
+ ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
+ if (ret) {
hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
- return -EINVAL;
+ return ret;
}
wrqu->data.length = strlen(extra);
EXIT();