From patchwork Fri Dec 2 09:28:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szymon Bigos X-Patchwork-Id: 128812 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B74CAB6F65 for ; Fri, 2 Dec 2011 20:28:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 1BE8B17C044; Fri, 2 Dec 2011 04:28:21 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qy83gh+8xu2x; Fri, 2 Dec 2011 04:28:20 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B8DA59D22C; Fri, 2 Dec 2011 04:28:16 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 401E69D22C for ; Fri, 2 Dec 2011 04:28:15 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G4TQ-PI9uwTO for ; Fri, 2 Dec 2011 04:28:09 -0500 (EST) Received: from ebb05.tieto.com (ebb05.tieto.com [131.207.168.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "ebb05.tieto.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id AC1F39D22A for ; Fri, 2 Dec 2011 04:28:09 -0500 (EST) X-AuditID: 83cfa824-b7cebae0000004d2-17-4ed89a2713b4 Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb05.tieto.com (SMTP Mailer) with SMTP id 04.3C.01234.72A98DE4; Fri, 2 Dec 2011 11:28:07 +0200 (EET) Received: from [10.28.23.118] (10.28.23.118) by inbound.tieto.com (131.207.136.49) with Microsoft SMTP Server id 8.3.159.2; Fri, 2 Dec 2011 11:28:07 +0200 Subject: [PATCH] Fix for wrong pin generating. From: Szymon Bigos To: Date: Fri, 2 Dec 2011 10:28:00 +0100 Message-ID: <1322818080.1889.1.camel@uw000724.wroclaw.emp> MIME-Version: 1.0 X-Mailer: Evolution 2.28.3 X-Brightmail-Tracker: AAAAAQPmCRA= X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com >From 6f8d1729544cbbe9fa172c73fd1bcf98a4e2daf8 Mon Sep 17 00:00:00 2001 From: Szymon Bigos 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) From 6f8d1729544cbbe9fa172c73fd1bcf98a4e2daf8 Mon Sep 17 00:00:00 2001 From: Szymon Bigos 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