Use common is_ctrl_char() helper function
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>
This commit is contained in:
parent
f371869a96
commit
0f5acfba06
4 changed files with 11 additions and 4 deletions
|
@ -161,8 +161,7 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
|
||||||
for (i = 0; i < nlen; i++) {
|
for (i = 0; i < nlen; i++) {
|
||||||
if (msg->device_name[i] == '\0')
|
if (msg->device_name[i] == '\0')
|
||||||
break;
|
break;
|
||||||
if (msg->device_name[i] > 0 &&
|
if (is_ctrl_char(msg->device_name[i]))
|
||||||
msg->device_name[i] < 32)
|
|
||||||
msg->device_name[i] = '_';
|
msg->device_name[i] = '_';
|
||||||
}
|
}
|
||||||
wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
|
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';
|
name[cli->dev_name_len] = '\0';
|
||||||
count = (int) cli->dev_name_len - 1;
|
count = (int) cli->dev_name_len - 1;
|
||||||
while (count >= 0) {
|
while (count >= 0) {
|
||||||
if (name[count] > 0 && name[count] < 32)
|
if (is_ctrl_char(name[count]))
|
||||||
name[count] = '_';
|
name[count] = '_';
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1088,3 +1088,9 @@ size_t utf8_escape(const char *inp, size_t in_size,
|
||||||
|
|
||||||
return res_size;
|
return res_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int is_ctrl_char(char c)
|
||||||
|
{
|
||||||
|
return c > 0 && c < 32;
|
||||||
|
}
|
||||||
|
|
|
@ -554,6 +554,7 @@ size_t utf8_escape(const char *inp, size_t in_size,
|
||||||
char *outp, size_t out_size);
|
char *outp, size_t out_size);
|
||||||
size_t utf8_unescape(const char *inp, size_t in_size,
|
size_t utf8_unescape(const char *inp, size_t in_size,
|
||||||
char *outp, size_t out_size);
|
char *outp, size_t out_size);
|
||||||
|
int is_ctrl_char(char c);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -618,7 +618,8 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
for (i = 0; i < attr.dev_name_len; i++) {
|
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] = '_';
|
str[i] = '_';
|
||||||
else
|
else
|
||||||
str[i] = attr.dev_name[i];
|
str[i] = attr.dev_name[i];
|
||||||
|
|
Loading…
Reference in a new issue