Merge branch 'bugfix/wep40_key_parsing_bug_v4.0' into 'release/v4.0'

wpa_supplicant: Add parsing support for WEP40 key(backport)

See merge request espressif/esp-idf!8684
This commit is contained in:
Jiang Jiang Jian 2020-05-12 20:17:15 +08:00
commit 12a65aaac1
2 changed files with 14 additions and 2 deletions

View file

@ -263,8 +263,7 @@ char * ets_strdup(const char *s);
#define os_strncpy(d, s, n) strncpy((d), (s), (n)) #define os_strncpy(d, s, n) strncpy((d), (s), (n))
#endif #endif
#ifndef os_strrchr #ifndef os_strrchr
//hard cold #define os_strrchr(s, c) strrchr((s), (c))
#define os_strrchr(s, c) NULL
#endif #endif
#ifndef os_strstr #ifndef os_strstr
#define os_strstr(h, n) strstr((h), (n)) #define os_strstr(h, n) strstr((h), (n))

View file

@ -269,8 +269,21 @@ char * wpa_config_parse_string(const char *value, size_t *len)
} else { } else {
u8 *str; u8 *str;
size_t tlen, hlen = os_strlen(value); size_t tlen, hlen = os_strlen(value);
#ifndef ESP_SUPPLICANT
if (hlen & 1) if (hlen & 1)
return NULL; 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; tlen = hlen / 2;
str = os_malloc(tlen + 1); str = os_malloc(tlen + 1);
if (str == NULL) if (str == NULL)