P2P: Filter control chars in group client device name similarly to peer

P2P device discovery can add peer entries based on a message directly
from a peer and from a Probe Response frame from a GO for all the P2P
Clients in the group. The former case for filtering out control
characters from the device name while the latter was not. Make this
consistent and filter both cases in the same way to avoid confusing
external programs using the device name of a P2P peer.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
master
Hu Wang 9 years ago committed by Jouni Malinen
parent f67d1a0099
commit 5d1d69a10f

@ -445,8 +445,9 @@ static struct p2p_device * p2p_create_device(struct p2p_data *p2p,
static void p2p_copy_client_info(struct p2p_device *dev,
struct p2p_client_info *cli)
{
os_memcpy(dev->info.device_name, cli->dev_name, cli->dev_name_len);
dev->info.device_name[cli->dev_name_len] = '\0';
p2p_copy_filter_devname(dev->info.device_name,
sizeof(dev->info.device_name),
cli->dev_name, cli->dev_name_len);
dev->info.dev_capab = cli->dev_capab;
dev->info.config_methods = cli->config_methods;
os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8);

@ -691,6 +691,8 @@ int p2p_channel_random_social(struct p2p_channels *chans, u8 *op_class,
u8 *op_channel);
/* p2p_parse.c */
void p2p_copy_filter_devname(char *dst, size_t dst_len,
const void *src, size_t src_len);
int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg);
int p2p_parse_ies(const u8 *data, size_t len, struct p2p_message *msg);
int p2p_parse(const u8 *data, size_t len, struct p2p_message *msg);

@ -15,11 +15,28 @@
#include "p2p_i.h"
void p2p_copy_filter_devname(char *dst, size_t dst_len,
const void *src, size_t src_len)
{
size_t i;
if (src_len >= dst_len)
src_len = dst_len - 1;
os_memcpy(dst, src, src_len);
dst[src_len] = '\0';
for (i = 0; i < src_len; i++) {
if (dst[i] == '\0')
break;
if (is_ctrl_char(dst[i]))
dst[i] = '_';
}
}
static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
struct p2p_message *msg)
{
const u8 *pos;
size_t i;
u16 nlen;
char devtype[WPS_DEV_TYPE_BUFSIZE];
@ -156,14 +173,8 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
(int) (data + len - pos));
return -1;
}
os_memcpy(msg->device_name, pos, nlen);
msg->device_name[nlen] = '\0';
for (i = 0; i < nlen; i++) {
if (msg->device_name[i] == '\0')
break;
if (is_ctrl_char(msg->device_name[i]))
msg->device_name[i] = '_';
}
p2p_copy_filter_devname(msg->device_name,
sizeof(msg->device_name), pos, nlen);
wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
" primary device type %s device name '%s' "
"config methods 0x%x",

Loading…
Cancel
Save