aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-11-29 18:50:00 (GMT)
committerJouni Malinen <j@w1.fi>2008-11-29 18:50:00 (GMT)
commite237a6b0d78db62c6b222dca07a008fe21c17f1f (patch)
tree00d5200bfd1aeebea7d146b4baaba10ff7b49b7a /wpa_supplicant
parente05716d0b078a1354ec3b25e8b6d67664a2e89e5 (diff)
downloadhostap-06-e237a6b0d78db62c6b222dca07a008fe21c17f1f.zip
hostap-06-e237a6b0d78db62c6b222dca07a008fe21c17f1f.tar.gz
hostap-06-e237a6b0d78db62c6b222dca07a008fe21c17f1f.tar.bz2
Fixed wpa_config_parse_string() not to modify const string.
This allows wpa_config_set() to be used with const strings as the value.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/config.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index c5e300e..6dff006 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -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);