aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHu Wang <huw@qti.qualcomm.com>2015-10-29 14:35:09 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-01-04 21:54:24 -0800
commit047069a6479c3d7eb5cf52fcbf2c8fd1143f931f (patch)
treed742cf6219b60b0ea90fcb743105aa6939c1ded6 /src
parent8cc5ff68960340807b79d85b9ddddef4cde11311 (diff)
downloadandroid_external_wpa_supplicant_8-047069a6479c3d7eb5cf52fcbf2c8fd1143f931f.tar.gz
android_external_wpa_supplicant_8-047069a6479c3d7eb5cf52fcbf2c8fd1143f931f.tar.bz2
android_external_wpa_supplicant_8-047069a6479c3d7eb5cf52fcbf2c8fd1143f931f.zip
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. CRs-fixed: 930000 Git-commit: 5d1d69a10f60eec624689408ec85fbe93657156d Git-repo : git://w1.fi/srv/git/hostap.git Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com> Change-Id: I5a22c6bbcc060c5e9b30b977a04915836b04f36f
Diffstat (limited to 'src')
-rw-r--r--src/p2p/p2p.c5
-rw-r--r--src/p2p/p2p_i.h2
-rw-r--r--src/p2p/p2p_parse.c30
3 files changed, 26 insertions, 11 deletions
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index b87ff96b..99bd402a 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -455,8 +455,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);
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index a1042d23..78e52c93 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -682,6 +682,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);
diff --git a/src/p2p/p2p_parse.c b/src/p2p/p2p_parse.c
index 980dddf1..afdef853 100644
--- a/src/p2p/p2p_parse.c
+++ b/src/p2p/p2p_parse.c
@@ -15,11 +15,29 @@
#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, nlen;
+ size_t nlen;
char devtype[WPS_DEV_TYPE_BUFSIZE];
switch (id) {
@@ -156,14 +174,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",