[PATCH] Add support of Passphrase Param in P2P group add command

Jouni Malinen j
Wed Jun 10 10:03:26 PDT 2015


On Mon, Jun 08, 2015 at 09:48:52AM +0530, Maneesh Jain wrote:
> This patch is to add "passphrase" parameter in
> "p2p_group_add" command. It helps application
> to configure its own passphrase while creating
> the group.
> It is most usefull in p2p legacy connection

> diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
> @@ -5532,16 +5533,30 @@ static int p2p_ctrl_group_add(struct wpa_supplicant *wpa_s, char *cmd)
> +	pos = os_strstr(cmd, "passphrase");

I'd assume that should be "passphrase=".

> +		passphrase = pos + 11;
> +		pos = os_strchr(passphrase, ' ');

Please note that ' ' is a valid character in a passphrase.. This type of
parsing would not work for such a case.

> +		if(pos != NULL)
> +			*pos = '\0';

This termination of the string can break the following steps:

>  	if (os_strncmp(cmd, "persistent=", 11) == 0)
...

This argument could have been after the passphrase= parameter.

> diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
> @@ -5365,13 +5365,14 @@ wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
> + * @passphrase : Start GO with assigned passphrase

>  int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group,
> -		       int freq, int ht40, int vht)
> +		       int freq, int ht40, int vht,  char *passphrase)

That should be "const char *".

> @@ -5412,6 +5413,10 @@ int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group,
> +	if(passphrase != NULL) {
> +		os_strlcpy(params.passphrase, passphrase, 64);

sizeof(params.passphrase) would be better than 64 here. In addition, it
would be good to verify somewhere (likely here) that
os_strlen(passphrase) is 8..63.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list