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
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 69f920d..4565329 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2216,8 +2216,16 @@
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;