aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Stewart <pstew@google.com>2016-03-03 23:40:19 (GMT)
committerJouni Malinen <j@w1.fi>2016-05-02 08:08:25 (GMT)
commit0fe5a234240a108b294a87174ad197f6b5cb38e9 (patch)
treea9ed54e2fded864a37fa8afc380e8dbc8b824ffe /src
parent5594df44c7cda554ab9d8bc8d8914fd5639a1c95 (diff)
downloadhostap-0fe5a234240a108b294a87174ad197f6b5cb38e9.zip
hostap-0fe5a234240a108b294a87174ad197f6b5cb38e9.tar.gz
hostap-0fe5a234240a108b294a87174ad197f6b5cb38e9.tar.bz2
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>
Diffstat (limited to 'src')
-rw-r--r--src/utils/common.c11
-rw-r--r--src/utils/common.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/common.c b/src/utils/common.c
index 27b7c02..9856463 100644
--- a/src/utils/common.c
+++ b/src/utils/common.c
@@ -709,6 +709,17 @@ int has_ctrl_char(const u8 *data, size_t len)
}
+int has_newline(const char *str)
+{
+ while (*str) {
+ if (*str == '\n' || *str == '\r')
+ return 1;
+ str++;
+ }
+ return 0;
+}
+
+
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/src/utils/common.h b/src/utils/common.h
index a972240..d19927b 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -489,6 +489,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);