Skip to content

Commit b356086

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/supplicant_analyzer_fixes' into 'master'
Bugfix/supplicant analyzer fixes Closes WIFIBUG-1218 and IDF-13129 See merge request espressif/esp-idf!39300
2 parents 45a9a31 + 17cd200 commit b356086

File tree

13 files changed

+43
-25
lines changed

13 files changed

+43
-25
lines changed

components/esp_wifi/wifi_apps/roaming_app/src/Kconfig.roaming

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ menu "Roaming Methods"
9393
config ESP_WIFI_NETWORK_ASSISTED_ROAMING_IP_RENEW_SKIP
9494
bool "Skip IP renew during BTM based roaming"
9595
depends on ESP_WIFI_ROAMING_NETWORK_ASSISTED_ROAM
96-
default y
96+
default n
9797
help
9898
Station will not ask for IP renew after a BTM based roaming. Before enabling please
9999
make sure your network supports this.

components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls-bignum.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -51,15 +51,20 @@ struct crypto_bignum *crypto_bignum_init_set(const u8 *buf, size_t len)
5151

5252
struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
5353
{
54+
int ret;
5455

5556
mbedtls_mpi *bn = os_zalloc(sizeof(mbedtls_mpi));
56-
if (bn == NULL) {
57+
if (!bn) {
5758
return NULL;
5859
}
5960

6061
mbedtls_mpi_init(bn);
61-
mbedtls_mpi_lset(bn, val);
62+
ret = mbedtls_mpi_lset(bn, val);
6263

64+
if (ret) {
65+
crypto_bignum_deinit((struct crypto_bignum *)bn, 0);
66+
bn = NULL;
67+
}
6368
return (struct crypto_bignum *)bn;
6469
}
6570

components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls-ec.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ struct wpabuf * crypto_ecdh_get_pubkey(struct crypto_ecdh *ecdh, int y)
11771177
{
11781178
struct wpabuf *public_key = NULL;
11791179
uint8_t *buf = NULL;
1180+
int ret;
11801181
mbedtls_ecdh_context *ctx = (mbedtls_ecdh_context *)ecdh;
11811182
size_t prime_len = ACCESS_ECDH(ctx, grp).pbits / 8;
11821183

@@ -1187,8 +1188,13 @@ struct wpabuf * crypto_ecdh_get_pubkey(struct crypto_ecdh *ecdh, int y)
11871188
}
11881189

11891190
/* Export an MPI into unsigned big endian binary data of fixed size */
1190-
mbedtls_mpi_write_binary(ACCESS_ECDH(&ctx, Q).MBEDTLS_PRIVATE(X), buf, prime_len);
1191+
ret = mbedtls_mpi_write_binary(ACCESS_ECDH(&ctx, Q).MBEDTLS_PRIVATE(X), buf, prime_len);
1192+
if (ret) {
1193+
goto cleanup;
1194+
}
11911195
public_key = wpabuf_alloc_copy(buf, 32);
1196+
1197+
cleanup:
11921198
os_free(buf);
11931199
return public_key;
11941200
}

components/wpa_supplicant/esp_supplicant/src/crypto/fastpbkdf2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static inline void md_pad(uint8_t *block, size_t blocksz, size_t used, size_t ms
109109
const uint8_t *key, size_t nkey) \
110110
{ \
111111
/* Prepare key: */ \
112-
uint8_t k[_blocksz]; \
112+
uint8_t k[_blocksz] = {0}; \
113113
\
114114
/* Shorten long keys. */ \
115115
if (nkey > _blocksz) \

components/wpa_supplicant/esp_supplicant/src/esp_wps.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,11 @@ int wps_process_wps_mX_req(u8 *ubuf, int len, enum wps_process_res *res)
641641
tlen = frag_len;
642642
}
643643

644+
if (tlen > 50000) {
645+
wpa_printf(MSG_ERROR, "EAP-WSC: Invalid Message Length");
646+
return ESP_FAIL;
647+
}
644648
if ((flag & WPS_MSG_FLAG_MORE) || wps_buf != NULL) {//frag msg
645-
if (tlen > 50000) {
646-
wpa_printf(MSG_ERROR, "EAP-WSC: Invalid Message Length");
647-
return ESP_FAIL;
648-
}
649649
wpa_printf(MSG_DEBUG, "rx frag msg id:%d, flag:%d, frag_len: %d, tot_len: %d, be_tot_len:%d", sm->current_identifier, flag, frag_len, tlen, be_tot_len);
650650
if (ESP_OK != wps_enrollee_process_msg_frag(&wps_buf, tlen, tbuf, frag_len, flag)) {
651651
if (wps_buf) {

components/wpa_supplicant/src/ap/wpa_auth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,7 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
16441644
SM_ENTRY_MA(WPA_PTK, PTKCALCNEGOTIATING, wpa_ptk);
16451645
sm->EAPOLKeyReceived = FALSE;
16461646
sm->update_snonce = FALSE;
1647+
os_memset(&PTK, 0, sizeof(PTK));
16471648
pmk_len = PMK_LEN;
16481649

16491650
/* WPA with IEEE 802.1X: use the derived PMK from EAP

components/wpa_supplicant/src/crypto/sha256-prf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int sha256_prf_bits(const u8 *key, size_t key_len, const char *label,
9797
* Mask out unused bits in the last octet if it does not use all the
9898
* bits.
9999
*/
100-
if (buf_len_bits % 8) {
100+
if (pos > 0 && (buf_len_bits % 8)) {
101101
u8 mask = 0xff << (8 - buf_len_bits % 8);
102102
buf[pos - 1] &= mask;
103103
}

components/wpa_supplicant/src/crypto/sha384-prf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int sha384_prf_bits(const u8 *key, size_t key_len, const char *label,
9797
* Mask out unused bits in the last octet if it does not use all the
9898
* bits.
9999
*/
100-
if (buf_len_bits % 8) {
100+
if (pos > 0 && (buf_len_bits % 8)) {
101101
u8 mask = 0xff << (8 - buf_len_bits % 8);
102102
buf[pos - 1] &= mask;
103103
}

components/wpa_supplicant/src/eap_peer/eap_fast_pac.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,9 @@ int eap_fast_load_pac(struct eap_sm *sm, struct eap_fast_pac **pac_root,
426426

427427
if (eap_fast_read_line(&rc, &pos) < 0) {
428428
/* empty file - assume it is fine to overwrite */
429-
printf("\n\nassuming it is fine to overwrite... \n\n");
430429
eap_fast_deinit_pac_data(&rc);
431430
return 0;
432431
}
433-
printf("\n\nPAC FILE =\n%s", rc.pos);
434432
if (os_strcmp(pac_file_hdr, rc.buf) != 0)
435433
err = "Unrecognized header line";
436434

@@ -546,11 +544,13 @@ static int eap_fast_write_pac(struct eap_sm *sm, const char *pac_file,
546544
blob->data = (u8 *) buf;
547545
blob->len = len;
548546
buf = NULL;
547+
#ifndef ESP_SUPPLICANT
549548
blob->name = os_strdup(pac_file + 7);
550549
if (blob->name == NULL) {
551550
os_free(blob);
552551
return -1;
553552
}
553+
#endif
554554
eap_set_config_blob(sm, blob);
555555
os_free(blob);
556556
} else {
@@ -657,7 +657,6 @@ int eap_fast_save_pac(struct eap_sm *sm, struct eap_fast_pac *pac_root,
657657
return -1;
658658
}
659659

660-
wpa_printf(MSG_DEBUG, "PAC file: %s", (sm->blob[3].data));
661660
wpa_printf(MSG_DEBUG, "EAP-FAST: Wrote %d PAC entries into '%s'",
662661
count, pac_file);
663662

@@ -755,8 +754,7 @@ int eap_fast_load_pac_bin(struct eap_sm *sm, struct eap_fast_pac **pac_root,
755754
{
756755
const struct wpa_config_blob *blob = NULL;
757756
u8 *buf, *end, *pos;
758-
size_t len = 0;
759-
size_t count = 0;
757+
size_t len, count = 0;
760758
struct eap_fast_pac *pac, *prev;
761759

762760
*pac_root = NULL;
@@ -776,6 +774,7 @@ int eap_fast_load_pac_bin(struct eap_sm *sm, struct eap_fast_pac **pac_root,
776774
len = blob->len;
777775
} else {
778776
buf = (u8 *) sm->blob[3].data; //(u8 *) os_readfile(pac_file, &len);
777+
len = sm->blob[3].len;
779778
if (buf == NULL) {
780779
wpa_printf(MSG_INFO, "EAP-FAST: No PAC file '%s' - "
781780
"assume no PAC entries have been "

components/wpa_supplicant/src/eap_peer/eap_ttls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void * eap_ttls_init(struct eap_sm *sm)
117117

118118

119119
static void eap_ttls_phase2_eap_deinit(struct eap_sm *sm,
120-
struct eap_ttls_data *data)
120+
struct eap_ttls_data *data)
121121
{
122122
if (data->phase2_priv && data->phase2_method) {
123123
data->phase2_method->deinit(sm, data->phase2_priv);
@@ -130,7 +130,7 @@ static void eap_ttls_phase2_eap_deinit(struct eap_sm *sm,
130130
static void eap_ttls_free_key(struct eap_ttls_data *data)
131131
{
132132
if (data->key_data) {
133-
bin_clear_free(data->key_data, EAP_TLS_KEY_LEN);
133+
bin_clear_free(data->key_data, EAP_TLS_KEY_LEN + EAP_EMSK_LEN);
134134
data->key_data = NULL;
135135
}
136136
}
@@ -153,7 +153,7 @@ static void eap_ttls_deinit(struct eap_sm *sm, void *priv)
153153

154154

155155
static u8 * eap_ttls_avp_hdr(u8 *avphdr, u32 avp_code, u32 vendor_id,
156-
int mandatory, size_t len)
156+
int mandatory, size_t len)
157157
{
158158
struct ttls_avp_vendor *avp;
159159
u8 flags;
@@ -170,7 +170,7 @@ static u8 * eap_ttls_avp_hdr(u8 *avphdr, u32 avp_code, u32 vendor_id,
170170
}
171171

172172
avp->avp_code = host_to_be32(avp_code);
173-
avp->avp_length = host_to_be32(((u32) (flags << 24)) |
173+
avp->avp_length = host_to_be32(((u32) flags << 24) |
174174
(u32) (hdrlen + len));
175175

176176
return avphdr + hdrlen;

0 commit comments

Comments
 (0)