diff mbox

Fix for wrong pin generating.

Message ID 1322818080.1889.1.camel@uw000724.wroclaw.emp
State Accepted
Commit 9337e876ab677facc850f4db682a7a8d9aed018c
Headers show

Commit Message

Szymon Bigos Dec. 2, 2011, 9:28 a.m. UTC
>From 6f8d1729544cbbe9fa172c73fd1bcf98a4e2daf8 Mon Sep 17 00:00:00 2001
From: Szymon Bigos <szymon.bigos@tieto.com>
Date: Fri, 2 Dec 2011 10:20:10 +0100
Subject: [PATCH] Fix for wrong pin generating.

Sometimes was generated pin with less then 8
digits, but zeros weren't added at the begining of string.
---
 src/ap/wps_hostapd.c |    2 +-
 wpa_supplicant/ap.c  |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

 		ret_len = os_snprintf(buf, buflen, "%s", pin);
@@ -772,7 +772,7 @@ const char * wpas_wps_ap_pin_random(struct
wpa_supplicant *wpa_s, int timeout)
 		return NULL;
 	hapd = wpa_s->ap_iface->bss[0];
 	pin = wps_generate_pin();
-	os_snprintf(pin_txt, sizeof(pin_txt), "%u", pin);
+	os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
 	os_free(hapd->conf->ap_pin);
 	hapd->conf->ap_pin = os_strdup(pin_txt);
 	if (hapd->conf->ap_pin == NULL)

Comments

Jouni Malinen Dec. 2, 2011, 9:07 p.m. UTC | #1
On Fri, Dec 02, 2011 at 10:28:00AM +0100, Szymon Bigos wrote:
> Sometimes was generated pin with less then 8
> digits, but zeros weren't added at the begining of string.

Thanks, applied.
diff mbox

Patch

From 6f8d1729544cbbe9fa172c73fd1bcf98a4e2daf8 Mon Sep 17 00:00:00 2001
From: Szymon Bigos <szymon.bigos@tieto.com>
Date: Fri, 2 Dec 2011 10:20:10 +0100
Subject: [PATCH] Fix for wrong pin generating.

Sometimes was generated pin with less then 8
digits, but zeros weren't added at the begining of string.
---
 src/ap/wps_hostapd.c |    2 +-
 wpa_supplicant/ap.c  |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c
index 60961fd..817012e 100644
--- a/src/ap/wps_hostapd.c
+++ b/src/ap/wps_hostapd.c
@@ -1350,7 +1350,7 @@  const char * hostapd_wps_ap_pin_random(struct hostapd_data *hapd, int timeout)
 	struct wps_ap_pin_data data;
 
 	pin = wps_generate_pin();
-	os_snprintf(data.pin_txt, sizeof(data.pin_txt), "%u", pin);
+	os_snprintf(data.pin_txt, sizeof(data.pin_txt), "%08u", pin);
 	data.timeout = timeout;
 	hostapd_wps_for_each(hapd, wps_ap_pin_set, &data);
 	return hapd->conf->ap_pin;
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index db0259d..4d186b9 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -711,7 +711,7 @@  int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
 
 	if (pin == NULL) {
 		unsigned int rpin = wps_generate_pin();
-		ret_len = os_snprintf(buf, buflen, "%d", rpin);
+		ret_len = os_snprintf(buf, buflen, "%08d", rpin);
 		pin = buf;
 	} else
 		ret_len = os_snprintf(buf, buflen, "%s", pin);
@@ -772,7 +772,7 @@  const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout)
 		return NULL;
 	hapd = wpa_s->ap_iface->bss[0];
 	pin = wps_generate_pin();
-	os_snprintf(pin_txt, sizeof(pin_txt), "%u", pin);
+	os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
 	os_free(hapd->conf->ap_pin);
 	hapd->conf->ap_pin = os_strdup(pin_txt);
 	if (hapd->conf->ap_pin == NULL)
-- 
1.7.0.4