summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkalikinkar dhara <c_kaliki@qca.qualcomm.com>2013-11-12 14:29:46 -0800
committerAkash Patel <c_akashp@qca.qualcomm.com>2014-06-18 21:12:47 -0700
commit8b568f92fe0738c855f575d8ef1dce9a6b066b75 (patch)
tree89131bb8808a1662d3a47cf481fefd72dc07ad69
parentcd3f7f2b48c6690e3b09bf757822a0f2cf0c4ee2 (diff)
Droidsec: sscanf parameter count check
Must check return value from sscanf to confirm that all variables were correctly assigned before subsequent referencing. Change-Id: Ifbe3a18aa60fbe2c83d40e7f0ecb4800548c439a CRs-fixed: 678384
-rw-r--r--CORE/HDD/src/wlan_hdd_p2p.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/CORE/HDD/src/wlan_hdd_p2p.c b/CORE/HDD/src/wlan_hdd_p2p.c
index c67d0d2c33d5..f8557c3b83ef 100644
--- a/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/CORE/HDD/src/wlan_hdd_p2p.c
@@ -1427,6 +1427,7 @@ int hdd_setP2pNoa( struct net_device *dev, tANI_U8 *command )
tP2pPsConfig NoA;
int count, duration, start_time;
char *param;
+ int ret;
param = strnchr(command, strlen(command), ' ');
if (param == NULL)
@@ -1436,9 +1437,15 @@ int hdd_setP2pNoa( struct net_device *dev, tANI_U8 *command )
return -EINVAL;
}
param++;
- sscanf(param, "%d %d %d", &count, &start_time, &duration);
+ ret = sscanf(param, "%d %d %d", &count, &start_time, &duration);
+ if (ret != 3) {
+ VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+ "%s: P2P_SET GO NoA: fail to read params, ret=%d",
+ __func__, ret);
+ return -EINVAL;
+ }
VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
- "%s: P2P_SET GO NoA: count=%d duration=%d interval=%d",
+ "%s: P2P_SET GO NoA: count=%d start_time=%d duration=%d",
__func__, count, start_time, duration);
duration = MS_TO_MUS(duration);
/* PS Selection
@@ -1504,6 +1511,7 @@ int hdd_setP2pOpps( struct net_device *dev, tANI_U8 *command )
tP2pPsConfig NoA;
char *param;
int legacy_ps, opp_ps, ctwindow;
+ int ret;
param = strnchr(command, strlen(command), ' ');
if (param == NULL)
@@ -1513,7 +1521,13 @@ int hdd_setP2pOpps( struct net_device *dev, tANI_U8 *command )
return -EINVAL;
}
param++;
- sscanf(param, "%d %d %d", &legacy_ps, &opp_ps, &ctwindow);
+ ret = sscanf(param, "%d %d %d", &legacy_ps, &opp_ps, &ctwindow);
+ if (ret != 3) {
+ VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+ "%s: P2P_SET GO PS: fail to read params, ret=%d",
+ __func__, ret);
+ return -EINVAL;
+ }
VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
"%s: P2P_SET GO PS: legacy_ps=%d opp_ps=%d ctwindow=%d",
__func__, legacy_ps, opp_ps, ctwindow);