From 398dc28a4ed2cba7f863d2e94dc7e1214e480028 Mon Sep 17 00:00:00 2001 From: "kapil.gupta" Date: Fri, 13 Mar 2020 15:52:44 +0530 Subject: [PATCH] wpa_supplicant: Add parsing support for WEP40 key WEP key is passed as ascii key without "", add parsing support in supplicant for this. --- components/wpa_supplicant/port/include/os.h | 3 +-- components/wpa_supplicant/src/utils/common.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/wpa_supplicant/port/include/os.h b/components/wpa_supplicant/port/include/os.h index 5a17259e5..fb66026bf 100644 --- a/components/wpa_supplicant/port/include/os.h +++ b/components/wpa_supplicant/port/include/os.h @@ -263,8 +263,7 @@ char * ets_strdup(const char *s); #define os_strncpy(d, s, n) strncpy((d), (s), (n)) #endif #ifndef os_strrchr -//hard cold -#define os_strrchr(s, c) NULL +#define os_strrchr(s, c) strrchr((s), (c)) #endif #ifndef os_strstr #define os_strstr(h, n) strstr((h), (n)) diff --git a/components/wpa_supplicant/src/utils/common.c b/components/wpa_supplicant/src/utils/common.c index 12d703ec9..ef2225b70 100644 --- a/components/wpa_supplicant/src/utils/common.c +++ b/components/wpa_supplicant/src/utils/common.c @@ -269,8 +269,21 @@ char * wpa_config_parse_string(const char *value, size_t *len) } else { u8 *str; size_t tlen, hlen = os_strlen(value); +#ifndef ESP_SUPPLICANT if (hlen & 1) return NULL; +#else + if (hlen == 5 || hlen == 13) { + *len = hlen; + str = (u8 *)os_malloc(*len + 1); + if (str == NULL) { + return NULL; + } + memcpy(str, value, *len); + str[*len] = '\0'; + return (char *) str; + } +#endif tlen = hlen / 2; str = os_malloc(tlen + 1); if (str == NULL)