diff options
author | Paul Stewart <pstew@google.com> | 2016-03-03 15:33:47 -0800 |
---|---|---|
committer | Paul Stewart <pstew@google.com> | 2016-03-03 16:16:00 -0800 |
commit | 85c72c6156e81a281e7596a1ebfaf355c56d1520 (patch) | |
tree | 48445aeb9d098bb55b130431281aec2dd5147f48 | |
parent | f5974f2cf32f25cea454ee1522d8fc56f37834c9 (diff) | |
download | wpa_supplicant_8-85c72c6156e81a281e7596a1ebfaf355c56d1520.tar.gz |
Remove newlines from config output
Spurious newlines output while writing the config file can
corrupt the wpa_supplicant configuration. Avoid writing these.
Bug: 27371366
Change-Id: I3bb99b8c46dba1c81cbccc76ed0cd01abc3ccef9
-rw-r--r-- | wpa_supplicant/config.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 69f920da..4565329b 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2216,8 +2216,16 @@ char * wpa_config_get(struct wpa_ssid *ssid, const char *var) for (i = 0; i < NUM_SSID_FIELDS; i++) { const struct parse_data *field = &ssid_fields[i]; - if (os_strcmp(var, field->name) == 0) - return field->writer(field, ssid); + if (os_strcmp(var, field->name) == 0) { + char *ret = field->writer(field, ssid); + if (os_strchr(ret, '\r') != NULL || os_strchr(ret, '\n') != NULL) { + wpa_printf(MSG_ERROR, "Found newline in value for %s; " + "not returning it", var); + os_free(ret); + ret = NULL; + } + return ret; + } } return NULL; |