Skip to content

Commit

Permalink
Merge branch 'bugfix/remove_redundant_debug_print' into 'master'
Browse files Browse the repository at this point in the history
Remove redundant DEBUG_PRINT in supplicant

Closes IDFGH-9037

See merge request espressif/esp-idf!21857
  • Loading branch information
jack0c committed Jan 18, 2023
2 parents 9f3fd28 + 68fb038 commit 3636495
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ static int tls_create_mbedtls_handle(struct tls_connection *conn,
#endif

/* Enable debug prints in case supplicant's prints are enabled */
#if defined(DEBUG_PRINT) && defined(CONFIG_MBEDTLS_DEBUG) && defined(ESPRESSIF_USE)
#if defined(CONFIG_MBEDTLS_DEBUG) && defined(ESPRESSIF_USE)
mbedtls_esp_enable_debug_log(&tls->conf, 2);
#endif
return 0;
Expand Down
10 changes: 0 additions & 10 deletions components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,10 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
}

if (len < sizeof(*hdr) + sizeof(*ehdr)) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA: EAPOL frame too short to be a WPA "
"EAPOL-Key (len %lu, expecting at least %lu)",
(unsigned long) len,
(unsigned long) sizeof(*hdr) + sizeof(*ehdr));
#endif
return ESP_FAIL;
}

Expand All @@ -537,38 +535,30 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss
plen = be_to_host16(hdr->length);
data_len = plen + sizeof(*hdr);

#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "IEEE 802.1X RX: version=%d type=%d length=%d",
hdr->version, hdr->type, plen);
#endif
if (hdr->version < EAPOL_VERSION) {
/* TODO: backwards compatibility */
}
if (hdr->type != IEEE802_1X_TYPE_EAP_PACKET) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA2: EAP frame (type %u) discarded, "
"not a EAP PACKET frame", hdr->type);
#endif
ret = -2;
goto _out;
}
if (plen > len - sizeof(*hdr) || plen < sizeof(*ehdr)) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA2: EAPOL frame payload size %lu "
"invalid (frame size %lu)",
(unsigned long) plen, (unsigned long) len);
#endif
ret = -2;
goto _out;
}

wpa_hexdump(MSG_MSGDUMP, "WPA2: RX EAPOL-EAP PACKET", tmp, len);

if (data_len < len) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA: ignoring %lu bytes after the IEEE "
"802.1X data\n", (unsigned long) len - data_len);
#endif
}

#ifdef EAP_PEER_METHOD
Expand Down
12 changes: 0 additions & 12 deletions components/wpa_supplicant/esp_supplicant/src/esp_wps.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,12 +933,10 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
}

if (len < sizeof(*hdr) + sizeof(*ehdr)) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA: EAPOL frame too short to be a WPA "
"EAPOL-Key (len %lu, expecting at least %lu)",
(unsigned long) len,
(unsigned long) sizeof(*hdr) + sizeof(*ehdr));
#endif
return ESP_OK;
}

Expand All @@ -950,47 +948,37 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
data_len = plen + sizeof(*hdr);
eap_len = be_to_host16(ehdr->length);

#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "IEEE 802.1X RX: version=%d type=%d length=%d",
hdr->version, hdr->type, plen);
#endif

if (hdr->version < EAPOL_VERSION) {
/* TODO: backwards compatibility */
}
if (hdr->type != IEEE802_1X_TYPE_EAP_PACKET) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPS: EAP frame (type %u) discarded, "
"not a EAP PACKET frame", hdr->type);
#endif
ret = 0;
goto out;
}
if (plen > len - sizeof(*hdr) || plen < sizeof(*ehdr)) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA: EAPOL frame payload size %lu "
"invalid (frame size %lu)",
(unsigned long) plen, (unsigned long) len);
#endif
ret = 0;
goto out;
}

wpa_hexdump(MSG_MSGDUMP, "WPA: RX EAPOL-EAP PACKET", tmp, len);

if (data_len < len) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA: ignoring %lu bytes after the IEEE "
"802.1X data", (unsigned long) len - data_len);
#endif
}

if (eap_len != plen) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "WPA: EAPOL length %lu "
"invalid (eapol length %lu)",
(unsigned long) eap_len, (unsigned long) plen);
#endif
ret = 0;
goto out;
}
Expand Down
1 change: 0 additions & 1 deletion components/wpa_supplicant/port/include/supplicant_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "sdkconfig.h"

#if CONFIG_WPA_DEBUG_PRINT
#define DEBUG_PRINT
#if defined(CONFIG_LOG_DEFAULT_LEVEL_DEBUG) || defined(CONFIG_LOG_DEFAULT_LEVEL_VERBOSE)
#define ELOOP_DEBUG
#endif
Expand Down
20 changes: 0 additions & 20 deletions components/wpa_supplicant/src/common/wpa_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
}

if (rsn_ie_len < sizeof(struct rsn_ie_hdr)) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie len too short %lu",
__func__, (unsigned long) rsn_ie_len);
#endif
return -1;
}

Expand All @@ -428,10 +426,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
if (hdr->elem_id != WLAN_EID_RSN ||
hdr->len != rsn_ie_len - 2 ||
WPA_GET_LE16(hdr->version) != RSN_VERSION) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: malformed ie or unknown version",
__func__);
#endif
return -2;
}

Expand All @@ -443,10 +439,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
} else if (left > 0) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie length mismatch, %u too much",
__func__, left);
#endif
return -3;
}

Expand All @@ -456,10 +450,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie count botch (pairwise), "
"count %u left %u", __func__, count, left);
#endif
return -4;
}
for (i = 0; i < count; i++) {
Expand All @@ -468,10 +460,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie too short (for key mgmt)",
__func__);
#endif
return -5;
}

Expand All @@ -481,10 +471,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie count botch (key mgmt), "
"count %u left %u", __func__, count, left);
#endif
return -6;
}
for (i = 0; i < count; i++) {
Expand All @@ -493,10 +481,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie too short (for capabilities)",
__func__);
#endif
return -7;
}

Expand All @@ -511,12 +497,10 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
pos += 2;
left -= 2;
if (left < (int) data->num_pmkid * PMKID_LEN) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: PMKID underflow "
"(num_pmkid=%lu left=%d)",
__func__, (unsigned long) data->num_pmkid,
left);
#endif
data->num_pmkid = 0;
return -9;
} else {
Expand All @@ -540,10 +524,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
}

if (left > 0) {
#ifdef DEBUG_PRINT
wpa_printf(MSG_DEBUG, "%s: ie has %u trailing bytes - ignored",
__func__, left);
#endif
}

return 0;
Expand Down Expand Up @@ -1033,7 +1015,6 @@ int rsn_pmkid_suite_b_192(const u8 *kck, size_t kck_len, const u8 *aa,
}
#endif /* CONFIG_SUITEB192 */

#ifdef DEBUG_PRINT
/**
* wpa_cipher_txt - Convert cipher suite to a text string
* @cipher: Cipher suite (WPA_CIPHER_* enum)
Expand Down Expand Up @@ -1066,7 +1047,6 @@ const char * wpa_cipher_txt(int cipher)
return "UNKNOWN";
}
}
#endif

/**
* wpa_pmk_to_ptk - Calculate PTK from PMK, addresses, and nonces
Expand Down
Loading

0 comments on commit 3636495

Please sign in to comment.