[WCNCR00166525] misc: fix coverity issue
[Description]
Fix CID 2190583, 2190586 Out-of-bounds write
Change-Id: I4d9e3caf5f4ba5fe6a69ec2e68bff0da9945fef1
CR-Id: WCNCR00166525
Signed-off-by: guo-jie.wang <guo-jie.wang@mediatek.com>
Feature: misc
Reviewed-on: http://gerrit.mediatek.inc:8080/1252399
CheckPatch: Check Patch <srv_checkpatch@mediatek.com>
Reviewed-by: George Kuo <george.kuo@mediatek.com>
Reviewed-by: Sarick Jiang <sarick.jiang@mediatek.com>
Build: srv_neptune_adm <srv_neptune_adm@mediatek.com>
diff --git a/common/wlan_oid.c b/common/wlan_oid.c
index 53c36c7..7fcbe8f 100644
--- a/common/wlan_oid.c
+++ b/common/wlan_oid.c
@@ -2547,6 +2547,12 @@
kalMemCopy(prCmdKey->aucPeerAddr, prBssInfo->aucOwnMacAddr, MAC_ADDR_LEN);
}
+ /* overflow check */
+ if (prCmdKey->ucKeyId >= MAX_KEY_NUM) {
+ DBGLOG(RSN, ERROR, "invalid keyId: %d\n", prCmdKey->ucKeyId);
+ prCmdKey->ucKeyId &= 0x3;
+ }
+
if (fgNoHandshakeSec) { /* WEP: STA and AP */
prBssInfo->wepkeyWlanIdx = prCmdKey->ucWlanIndex;
prBssInfo->wepkeyUsed[prCmdKey->ucKeyId] = TRUE;
@@ -2559,6 +2565,7 @@
DBGLOG(RSN, INFO, "BMCWlanIndex kid = %d, index = %d\n", prCmdKey->ucKeyId,
prCmdKey->ucWlanIndex);
}
+
if (prCmdKey->ucTxKey) { /* */
prBssInfo->fgBcDefaultKeyExist = TRUE;
prBssInfo->ucBcDefaultKeyIdx = prCmdKey->ucKeyId;