Fixed wpa_config_parse_string() not to modify const string.
This allows wpa_config_set() to be used with const strings as the value.
This commit is contained in:
parent
e05716d0b0
commit
e237a6b0d7
1 changed files with 9 additions and 4 deletions
|
@ -60,14 +60,19 @@ struct parse_data {
|
||||||
static char * wpa_config_parse_string(const char *value, size_t *len)
|
static char * wpa_config_parse_string(const char *value, size_t *len)
|
||||||
{
|
{
|
||||||
if (*value == '"') {
|
if (*value == '"') {
|
||||||
char *pos;
|
const char *pos;
|
||||||
|
char *str;
|
||||||
value++;
|
value++;
|
||||||
pos = os_strrchr(value, '"');
|
pos = os_strrchr(value, '"');
|
||||||
if (pos == NULL || pos[1] != '\0')
|
if (pos == NULL || pos[1] != '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
*pos = '\0';
|
*len = pos - value;
|
||||||
*len = os_strlen(value);
|
str = os_malloc(*len + 1);
|
||||||
return os_strdup(value);
|
if (str == NULL)
|
||||||
|
return NULL;
|
||||||
|
os_memcpy(str, value, *len);
|
||||||
|
str[*len] = '\0';
|
||||||
|
return str;
|
||||||
} else {
|
} else {
|
||||||
u8 *str;
|
u8 *str;
|
||||||
size_t tlen, hlen = os_strlen(value);
|
size_t tlen, hlen = os_strlen(value);
|
||||||
|
|
Loading…
Reference in a new issue