From 09697aa1433abe1e46e4a1b5566d3a17cd4b27a9 Mon Sep 17 00:00:00 2001
From: Isaac Chiou <isaacchiou@google.com>
Date: Tue, 23 Mar 2021 16:37:48 +0800
Subject: [PATCH] Wifi: Support NVT-ASCII in passphrase
Create a new function has_non_nvt_ascii_char which allows the following
control characters to be a part of a PSK passphrase
7 (Bell)
8 (Backspace)
9 (Horizontal tab)
10 (Line feed)
11 (Vertical tab)
12 (Form feed)
13 (Carriage return)
Signed-off-by: Isaac Chiou <isaacchiou@google.com>
---
src/utils/common.c | 14 ++++++++++++++
src/utils/common.h | 1 +
2 files changed, 15 insertions(+)
@@ -720,6 +720,20 @@ int has_ctrl_char(const u8 *data, size_t len)
}
+int has_non_nvt_ascii_char(const u8 *data, size_t len)
+{
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (data[i] < 7
+ || (13 < data[i] && data[i] < 32)
+ || data[i] == 127)
+ return 1;
+ }
+ return 0;
+}
+
+
int has_newline(const char *str)
{
while (*str) {
@@ -509,6 +509,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_non_nvt_ascii_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,
--
2.31.0.rc2.261.g7f71774620-goog