qcacld-2.0: Validate CCXBEACONREQ IE fields
Validate CCXBEACONREQ IE fields.
Change-Id: Ie64a642abdd7923e91801186aa5743094a739fc9
CRs-Fixed: 1025185
diff --git a/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c b/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c
index 2d5e01d..6dfb367 100755
--- a/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c
+++ b/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c
@@ -4686,7 +4686,8 @@
tCsrEseBeaconReq *pEseBcnReq)
{
tANI_U8 *inPtr = pValue;
- int tempInt = 0;
+ uint8_t input = 0;
+ uint32_t tempInt = 0;
int j = 0, i = 0, v = 0;
char buf[32];
@@ -4712,11 +4713,11 @@
v = sscanf(inPtr, "%31s ", buf);
if (1 != v) return -EINVAL;
- v = kstrtos32(buf, 10, &tempInt);
+ v = kstrtou8(buf, 10, &input);
if ( v < 0) return -EINVAL;
- tempInt = VOS_MIN(tempInt, SIR_ESE_MAX_MEAS_IE_REQS);
- pEseBcnReq->numBcnReqIe = tempInt;
+ input = VOS_MIN(input, SIR_ESE_MAX_MEAS_IE_REQS);
+ pEseBcnReq->numBcnReqIe = input;
hddLog(LOG1, "Number of Bcn Req Ie fields: %d", pEseBcnReq->numBcnReqIe);
@@ -4738,27 +4739,27 @@
v = sscanf(inPtr, "%31s ", buf);
if (1 != v) return -EINVAL;
- v = kstrtos32(buf, 10, &tempInt);
+ v = kstrtou32(buf, 10, &tempInt);
if (v < 0) return -EINVAL;
switch (i)
{
case 0: /* Measurement token */
- if (tempInt <= 0)
+ if (!tempInt)
{
VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
- "Invalid Measurement Token(%d)", tempInt);
+ "Invalid Measurement Token: %d", tempInt);
return -EINVAL;
}
pEseBcnReq->bcnReq[j].measurementToken = tempInt;
break;
case 1: /* Channel number */
- if ((tempInt <= 0) ||
+ if ((!tempInt) ||
(tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
{
VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
- "Invalid Channel Number(%d)", tempInt);
+ "Invalid Channel Number: %d", tempInt);
return -EINVAL;
}
pEseBcnReq->bcnReq[j].channel = tempInt;
@@ -4768,18 +4769,18 @@
if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE))
{
VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
- "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt);
+ "Invalid Scan Mode: %d Expected{0|1|2}", tempInt);
return -EINVAL;
}
pEseBcnReq->bcnReq[j].scanMode= tempInt;
break;
case 3: /* Measurement duration */
- if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) ||
- ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE)))
+ if (((!tempInt) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) ||
+ ((pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE)))
{
VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
- "Invalid Measurement Duration(%d)", tempInt);
+ "Invalid Measurement Duration: %d", tempInt);
return -EINVAL;
}
pEseBcnReq->bcnReq[j].measurementDuration = tempInt;