forked from espressif/esp-idf
fix(wpa_supplicant): Fix some coverity issues in wpa_supplicant
1. Fix leak in SoftAP while sending SAE Confirm 2. Move NULL check before pointer is getting used 3. Remove some dead code
This commit is contained in:
@@ -1164,6 +1164,10 @@ struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
|
||||
int secret_key = 0;
|
||||
|
||||
mbedtls_ecdh_context *ctx = (mbedtls_ecdh_context *)ecdh;
|
||||
if (!ctx) {
|
||||
wpa_printf(MSG_ERROR, "ECDH Context is NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
mbedtls_entropy_context entropy;
|
||||
@@ -1217,7 +1221,7 @@ struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
|
||||
|
||||
/* Setup ECDH context from EC key */
|
||||
/* Call to mbedtls_ecdh_get_params() will initialize the context when not LEGACY context */
|
||||
if (ctx != NULL && peer != NULL) {
|
||||
if (peer != NULL) {
|
||||
mbedtls_ecp_copy(ACCESS_ECDH(&ctx, Qp), &(mbedtls_pk_ec(*peer))->MBEDTLS_PRIVATE(Q));
|
||||
#ifndef CONFIG_MBEDTLS_ECDH_LEGACY_CONTEXT
|
||||
ctx->MBEDTLS_PRIVATE(var) = MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0;
|
||||
|
@@ -179,6 +179,7 @@ static int auth_sae_send_confirm(struct hostapd_data *hapd,
|
||||
#ifdef ESP_SUPPLICANT
|
||||
if (sta->remove_pending) {
|
||||
reply_res = -1;
|
||||
wpabuf_free(data);
|
||||
} else {
|
||||
if (sta->sae_data)
|
||||
wpabuf_free(sta->sae_data);
|
||||
|
@@ -2718,8 +2718,6 @@ struct wpa_sm * get_wpa_sm(void)
|
||||
int wpa_sm_set_ap_rsnxe(const u8 *ie, size_t len)
|
||||
{
|
||||
struct wpa_sm *sm = &gWpaSm;
|
||||
if (!sm)
|
||||
return -1;
|
||||
|
||||
os_free(sm->ap_rsnxe);
|
||||
if (!ie || len == 0) {
|
||||
|
Reference in New Issue
Block a user