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:
Jouni Malinen 2008-11-29 20:50:00 +02:00
parent e05716d0b0
commit e237a6b0d7

View file

@ -60,14 +60,19 @@ struct parse_data {
static char * wpa_config_parse_string(const char *value, size_t *len)
{
if (*value == '"') {
char *pos;
const char *pos;
char *str;
value++;
pos = os_strrchr(value, '"');
if (pos == NULL || pos[1] != '\0')
return NULL;
*pos = '\0';
*len = os_strlen(value);
return os_strdup(value);
*len = pos - value;
str = os_malloc(*len + 1);
if (str == NULL)
return NULL;
os_memcpy(str, value, *len);
str[*len] = '\0';
return str;
} else {
u8 *str;
size_t tlen, hlen = os_strlen(value);