[PATCH] P2P: Add error message for invalid PIN

Jouni Malinen j at w1.fi
Sat Jun 30 14:31:37 EDT 2012


On Tue, Mar 06, 2012 at 08:49:58PM +0900, Masashi Honma wrote:
> Thanks for your advice. I relaxed the restriction of new patch.

Thanks, applied.

> diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
> @@ -2750,6 +2752,13 @@ static int p2p_ctrl_connect(struct
> +		val = strtol(pin, &end, 10);
> +		val = val; // workaround for a compiler warning
> +		if ((os_strlen(pin) != 4 && os_strlen(pin) != 8) ||
> +		    *end != '\0') {

Though, I replaced that val = val; workaround with val < 0 check to
avoid accepting values like "-123" as a valid PIN. This would still
accept "+123".. I ended up moving this to a common WPS function and
implementing the validation with a loop that verifies that each
character is a digit to avoid that type of corner cases.

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list