]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use common is_ctrl_char() helper function
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 7 Apr 2015 12:43:32 +0000 (15:43 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 22 Apr 2015 08:44:19 +0000 (11:44 +0300)
This modifies couple of code segments that replaced control characters
in strings with '_' to use a common helper function.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/p2p/p2p_parse.c
src/utils/common.c
src/utils/common.h
src/wps/wps.c

index 44b00984c3516461f020ba8b4d6af6984b6e0fa9..def41ff51d37197100e62456d080ce1bca84c759 100644 (file)
@@ -161,8 +161,7 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
                for (i = 0; i < nlen; i++) {
                        if (msg->device_name[i] == '\0')
                                break;
-                       if (msg->device_name[i] > 0 &&
-                           msg->device_name[i] < 32)
+                       if (is_ctrl_char(msg->device_name[i]))
                                msg->device_name[i] = '_';
                }
                wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
@@ -743,7 +742,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
                name[cli->dev_name_len] = '\0';
                count = (int) cli->dev_name_len - 1;
                while (count >= 0) {
-                       if (name[count] > 0 && name[count] < 32)
+                       if (is_ctrl_char(name[count]))
                                name[count] = '_';
                        count--;
                }
index c31717c773ff94ea91cda10edfb2ec64d71e489a..5cf0d571bb0d87d1ef10e554a44888a76c268b09 100644 (file)
@@ -1088,3 +1088,9 @@ size_t utf8_escape(const char *inp, size_t in_size,
 
        return res_size;
 }
+
+
+int is_ctrl_char(char c)
+{
+       return c > 0 && c < 32;
+}
index a0eda4a2c48bb8054f0a8a96e814d46581aae6e8..88318f5d255a71e20f358b940b5122297b63e1ae 100644 (file)
@@ -554,6 +554,7 @@ size_t utf8_escape(const char *inp, size_t in_size,
                   char *outp, size_t out_size);
 size_t utf8_unescape(const char *inp, size_t in_size,
                     char *outp, size_t out_size);
+int is_ctrl_char(char c);
 
 
 /*
index 2c68be8c62ea05394ca4b8ee2f5746261439dccd..498f11f050afc7bbc2d25eacde017e908f145ef4 100644 (file)
@@ -618,7 +618,8 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
                if (str == NULL)
                        return pos - buf;
                for (i = 0; i < attr.dev_name_len; i++) {
-                       if (attr.dev_name[i] < 32)
+                       if (attr.dev_name[i] == 0 ||
+                           is_ctrl_char(attr.dev_name[i]))
                                str[i] = '_';
                        else
                                str[i] = attr.dev_name[i];