Explorar el Código

wpa_supplicant: Fix invalid pointer deference and memleak

Add following changes as part of this:

1. EAP client will crash during validation of key size when CA
certs and keys not present. Add changes to validate it first.
2. Free memory allocated in TLS context
kapil.gupta hace 5 años
padre
commit
1d59af5c84
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      components/wpa_supplicant/src/crypto/tls_mbedtls.c

+ 2 - 1
components/wpa_supplicant/src/crypto/tls_mbedtls.c

@@ -384,7 +384,7 @@ static void tls_set_ciphersuite(tls_context_t *tls)
 	if (tls->ciphersuite[0]) {
 		mbedtls_ssl_conf_ciphersuites(&tls->conf, tls->ciphersuite);
 	} else if (mbedtls_pk_get_bitlen(&tls->clientkey) > 2048 ||
-		 mbedtls_pk_get_bitlen(&tls->cacert_ptr->pk) > 2048) {
+		(tls->cacert_ptr && mbedtls_pk_get_bitlen(&tls->cacert_ptr->pk) > 2048)) {
 		mbedtls_ssl_conf_ciphersuites(&tls->conf, eap_ciphersuite_preference);
 	}
 }
@@ -504,6 +504,7 @@ void tls_connection_deinit(void *tls_ctx, struct tls_connection *conn)
 {
 	/* Free ssl ctx and data */
 	tls_mbedtls_conn_delete((tls_context_t *) conn->tls);
+	os_free(conn->tls);
 	conn->tls = NULL;
 	/* Data in in ssl ctx, free connection */
 	os_free(conn);