浏览代码

qcacld-3.0: Update wep_key length in mlme_get_wep_key

In mlme_get_wep_key, the key_length is got from the caller is
hardcoded to value 13. This should be updated based on the
length of the key and passed to the caller. But it is not
updated and value 13 is used to copy the key, resulting in
decrypt failure.
Also add debug logs to print wep key id and length.

Pass the key length by call by reference to update the key
length

Change-Id: Ie1e56a80db27894bf9f0426728f9fb74a014679e
CRs-Fixed: 2351182
Pragaspathi Thilagaraj 6 年之前
父节点
当前提交
129d6979e8

+ 1 - 1
components/mlme/dispatcher/inc/wlan_mlme_api.h

@@ -73,7 +73,7 @@ QDF_STATUS wlan_mlme_get_edca_params(struct wlan_mlme_edca_params *edca_params,
  */
  */
 QDF_STATUS mlme_get_wep_key(struct wlan_mlme_wep_cfg *wep_params,
 QDF_STATUS mlme_get_wep_key(struct wlan_mlme_wep_cfg *wep_params,
 			    enum wep_key_id wep_keyid, uint8_t *default_key,
 			    enum wep_key_id wep_keyid, uint8_t *default_key,
-			    qdf_size_t key_len);
+			    qdf_size_t *key_len);
 
 
 /**
 /**
  * mlme_set_wep_key() - set the wep keys during auth
  * mlme_set_wep_key() - set the wep keys during auth

+ 7 - 6
components/mlme/dispatcher/src/wlan_mlme_api.c

@@ -2099,37 +2099,38 @@ QDF_STATUS wlan_mlme_get_edca_params(struct wlan_mlme_edca_params *edca_params,
 
 
 QDF_STATUS mlme_get_wep_key(struct wlan_mlme_wep_cfg *wep_params,
 QDF_STATUS mlme_get_wep_key(struct wlan_mlme_wep_cfg *wep_params,
 			    enum wep_key_id wep_keyid, uint8_t *default_key,
 			    enum wep_key_id wep_keyid, uint8_t *default_key,
-			    qdf_size_t key_len)
+			    qdf_size_t *key_len)
 {
 {
 	switch (wep_keyid) {
 	switch (wep_keyid) {
 	case MLME_WEP_DEFAULT_KEY_1:
 	case MLME_WEP_DEFAULT_KEY_1:
 		wlan_mlme_get_cfg_str(default_key,
 		wlan_mlme_get_cfg_str(default_key,
 				      &wep_params->wep_default_key_1,
 				      &wep_params->wep_default_key_1,
-				      &key_len);
+				      key_len);
 		break;
 		break;
 
 
 	case MLME_WEP_DEFAULT_KEY_2:
 	case MLME_WEP_DEFAULT_KEY_2:
 		wlan_mlme_get_cfg_str(default_key,
 		wlan_mlme_get_cfg_str(default_key,
 				      &wep_params->wep_default_key_2,
 				      &wep_params->wep_default_key_2,
-				      &key_len);
+				      key_len);
 		break;
 		break;
 
 
 	case MLME_WEP_DEFAULT_KEY_3:
 	case MLME_WEP_DEFAULT_KEY_3:
 		wlan_mlme_get_cfg_str(default_key,
 		wlan_mlme_get_cfg_str(default_key,
 				      &wep_params->wep_default_key_3,
 				      &wep_params->wep_default_key_3,
-				      &key_len);
+				      key_len);
 		break;
 		break;
 
 
 	case MLME_WEP_DEFAULT_KEY_4:
 	case MLME_WEP_DEFAULT_KEY_4:
 		wlan_mlme_get_cfg_str(default_key,
 		wlan_mlme_get_cfg_str(default_key,
 				      &wep_params->wep_default_key_4,
 				      &wep_params->wep_default_key_4,
-				      &key_len);
+				      key_len);
 		break;
 		break;
 
 
 	default:
 	default:
 		mlme_err("Invalid key id:%d", wep_keyid);
 		mlme_err("Invalid key id:%d", wep_keyid);
 		return QDF_STATUS_E_INVAL;
 		return QDF_STATUS_E_INVAL;
 	}
 	}
+	mlme_debug("key_id:%d key_len:%zd", wep_keyid, *key_len);
 	return QDF_STATUS_SUCCESS;
 	return QDF_STATUS_SUCCESS;
 }
 }
 
 
@@ -2138,10 +2139,10 @@ QDF_STATUS mlme_set_wep_key(struct wlan_mlme_wep_cfg *wep_params,
 			    qdf_size_t len)
 			    qdf_size_t len)
 {
 {
 	if (len == 0) {
 	if (len == 0) {
-		mlme_debug("WEP set key length is zero");
 		return QDF_STATUS_E_FAILURE;
 		return QDF_STATUS_E_FAILURE;
 	}
 	}
 
 
+	mlme_debug("WEP set key for key_id:%d key_len:%zd", wep_keyid, len);
 	switch (wep_keyid) {
 	switch (wep_keyid) {
 	case MLME_WEP_DEFAULT_KEY_1:
 	case MLME_WEP_DEFAULT_KEY_1:
 		wlan_mlme_set_cfg_str(key_to_set,
 		wlan_mlme_set_cfg_str(key_to_set,

+ 8 - 4
core/mac/src/pe/lim/lim_process_auth_frame.c

@@ -564,7 +564,8 @@ static void lim_process_auth_frame_type2(tpAniSirGlobal mac_ctx,
 		tpPESession pe_session)
 		tpPESession pe_session)
 {
 {
 	uint8_t key_id, cfg_privacy_opt_imp;
 	uint8_t key_id, cfg_privacy_opt_imp;
-	uint32_t val, key_length = 8;
+	uint32_t key_length = 8;
+	qdf_size_t val;
 	uint8_t defaultkey[SIR_MAC_KEY_LENGTH];
 	uint8_t defaultkey[SIR_MAC_KEY_LENGTH];
 	struct tLimPreAuthNode *auth_node;
 	struct tLimPreAuthNode *auth_node;
 	uint8_t *encr_auth_frame;
 	uint8_t *encr_auth_frame;
@@ -758,7 +759,8 @@ static void lim_process_auth_frame_type2(tpAniSirGlobal mac_ctx,
 		} else {
 		} else {
 			qdf_status = mlme_get_wep_key(wep_params,
 			qdf_status = mlme_get_wep_key(wep_params,
 						      (MLME_WEP_DEFAULT_KEY_1 +
 						      (MLME_WEP_DEFAULT_KEY_1 +
-						      key_id), defaultkey, val);
+						       key_id), defaultkey,
+						      &val);
 			if (QDF_IS_STATUS_ERROR(qdf_status)) {
 			if (QDF_IS_STATUS_ERROR(qdf_status)) {
 				pe_warn("cant retrieve Defaultkey");
 				pe_warn("cant retrieve Defaultkey");
 
 
@@ -1121,7 +1123,8 @@ lim_process_auth_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
 	uint8_t *plainbody = NULL;
 	uint8_t *plainbody = NULL;
 	uint8_t decrypt_result;
 	uint8_t decrypt_result;
 	uint16_t frame_len, curr_seq_num = 0, auth_alg;
 	uint16_t frame_len, curr_seq_num = 0, auth_alg;
-	uint32_t val, key_length = 8;
+	uint32_t key_length = 8;
+	qdf_size_t val;
 	tSirMacAuthFrameBody *rx_auth_frm_body, *rx_auth_frame, *auth_frame;
 	tSirMacAuthFrameBody *rx_auth_frm_body, *rx_auth_frame, *auth_frame;
 	tpSirMacMgmtHdr mac_hdr;
 	tpSirMacMgmtHdr mac_hdr;
 	struct tLimPreAuthNode *auth_node;
 	struct tLimPreAuthNode *auth_node;
@@ -1362,7 +1365,8 @@ lim_process_auth_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
 		} else {
 		} else {
 			qdf_status = mlme_get_wep_key(wep_params,
 			qdf_status = mlme_get_wep_key(wep_params,
 						      (MLME_WEP_DEFAULT_KEY_1 +
 						      (MLME_WEP_DEFAULT_KEY_1 +
-						      key_id), defaultkey, val);
+						      key_id), defaultkey,
+						      &val);
 			if (QDF_IS_STATUS_ERROR(qdf_status)) {
 			if (QDF_IS_STATUS_ERROR(qdf_status)) {
 				pe_warn("could not retrieve Default key");
 				pe_warn("could not retrieve Default key");
 
 

+ 2 - 2
core/wma/src/wma_mgmt.c

@@ -1725,7 +1725,7 @@ static void wma_read_cfg_wepkey(tp_wma_handle wma_handle,
 				uint8_t *num_keys)
 				uint8_t *num_keys)
 {
 {
 	QDF_STATUS status;
 	QDF_STATUS status;
-	uint32_t val = SIR_MAC_KEY_LENGTH;
+	qdf_size_t val = SIR_MAC_KEY_LENGTH;
 	uint8_t i, j;
 	uint8_t i, j;
 	tpAniSirGlobal mac_ctx = wma_handle->mac_context;
 	tpAniSirGlobal mac_ctx = wma_handle->mac_context;
 
 
@@ -1737,7 +1737,7 @@ static void wma_read_cfg_wepkey(tp_wma_handle wma_handle,
 	for (i = 0, j = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++) {
 	for (i = 0, j = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++) {
 		status = mlme_get_wep_key(&mac_ctx->mlme_cfg->wep_params,
 		status = mlme_get_wep_key(&mac_ctx->mlme_cfg->wep_params,
 					  (MLME_WEP_DEFAULT_KEY_1 +
 					  (MLME_WEP_DEFAULT_KEY_1 +
-					  i), key_info[j].key, val);
+					  i), key_info[j].key, &val);
 		if (QDF_IS_STATUS_ERROR(status)) {
 		if (QDF_IS_STATUS_ERROR(status)) {
 			WMA_LOGE("WEP key is not configured at :%d", i);
 			WMA_LOGE("WEP key is not configured at :%d", i);
 		} else {
 		} else {