From b79e09574e50e168dd5f19d540ae0b9a05bd1535 Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Thu, 3 Mar 2016 15:33:47 -0800 Subject: 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 --- wpa_supplicant/config.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 4d801ccf..4051ae17 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2602,8 +2602,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; -- cgit v1.2.3