aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Stewart <pstew@google.com>2016-03-03 15:40:19 -0800
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:07:36 -0600
commite752a617e8eb7130e618a8ef13b9ff70998923f0 (patch)
tree8b167610077db99d19e50e643affa2e16f57365c
parent1f27e583846f77c792f5afaa2c0e7849b1f87734 (diff)
downloadandroid_external_wpa_supplicant_8-e752a617e8eb7130e618a8ef13b9ff70998923f0.tar.gz
android_external_wpa_supplicant_8-e752a617e8eb7130e618a8ef13b9ff70998923f0.tar.bz2
android_external_wpa_supplicant_8-e752a617e8eb7130e618a8ef13b9ff70998923f0.zip
Remove newlines from wpa_supplicant config network output
Spurious newlines output while writing the config file can corrupt the wpa_supplicant configuration. Avoid writing these for the network block parameters. This is a generic filter that cover cases that may not have been explicitly addressed with a more specific commit to avoid control characters in the psk parameter. Signed-off-by: Paul Stewart <pstew@google.com> Git-commit: 0fe5a234240a108b294a87174ad197f6b5cb38e9 Git-repo: git://w1.fi/srv/git/hostap.git Change-Id: I35e8483bdda5c391b95da42c2f577d5e9217f2e2 CRs-fixed: 1007548
-rw-r--r--src/utils/common.c9
-rw-r--r--src/utils/common.h1
-rw-r--r--wpa_supplicant/config.c9
3 files changed, 15 insertions, 4 deletions
diff --git a/src/utils/common.c b/src/utils/common.c
index fe10c23b..d57df3c4 100644
--- a/src/utils/common.c
+++ b/src/utils/common.c
@@ -696,6 +696,15 @@ int is_hex(const u8 *data, size_t len)
return 0;
}
+int has_newline(const char *str)
+{
+ while (*str) {
+ if (*str == '\n' || *str == '\r')
+ return 1;
+ str++;
+ }
+ return 0;
+}
int has_ctrl_char(const u8 *data, size_t len)
{
diff --git a/src/utils/common.h b/src/utils/common.h
index d858ea47..98aa731c 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -481,6 +481,7 @@ const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
char * wpa_config_parse_string(const char *value, size_t *len);
int is_hex(const u8 *data, size_t len);
int has_ctrl_char(const u8 *data, size_t len);
+int has_newline(const char *str);
size_t merge_byte_arrays(u8 *res, size_t res_len,
const u8 *src1, size_t src1_len,
const u8 *src2, size_t src2_len);
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 9082325f..ecc63a01 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2701,14 +2701,15 @@ char * wpa_config_get(struct wpa_ssid *ssid, const char *var)
const struct parse_data *field = &ssid_fields[i];
if (os_strcmp(var, field->name) == 0) {
char *ret = field->writer(field, ssid);
- if (ret != NULL && (os_strchr(ret, '\r') != NULL ||
- os_strchr(ret, '\n') != NULL)) {
+
+ if (ret && has_newline(ret)) {
wpa_printf(MSG_ERROR,
- "Found newline in value for %s; "
- "not returning it", var);
+ "Found newline in value for %s; not returning it",
+ var);
os_free(ret);
ret = NULL;
}
+
return ret;
}
}