[PATCH 09/10] Switch from using os_random() to using os_get_random(...) in wpas_auth_failed(...)

Nick Lowe nick.lowe at lugatech.com
Sun Feb 14 11:41:19 PST 2016


 Switch from using os_random() to using
 os_get_random(...) in wpas_auth_failed(...) The intention is to facilitate
 the future removal of os_random(). os_random() uses a low quality PRNG which
 we should avoid using outright unless there is a compelling performance
 justification to do so.

Signed-off-by: Nick Lowe <nick.lowe at lugatech.com>
---
 wpa_supplicant/wpa_supplicant.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index c3c1f14..ca0566a 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -5669,7 +5669,7 @@ int wpas_is_p2p_prioritized(struct wpa_supplicant *wpa_s)
 void wpas_auth_failed(struct wpa_supplicant *wpa_s, char *reason)
 {
     struct wpa_ssid *ssid = wpa_s->current_ssid;
-    int dur;
+    int dur, r;
     struct os_reltime now;

     if (ssid == NULL) {
@@ -5710,8 +5710,9 @@ void wpas_auth_failed(struct wpa_supplicant
*wpa_s, char *reason)
         dur = 10;

     if (ssid->auth_failures > 1 &&
-        wpa_key_mgmt_wpa_ieee8021x(ssid->key_mgmt))
-        dur += os_random() % (ssid->auth_failures * 10);
+            wpa_key_mgmt_wpa_ieee8021x(ssid->key_mgmt) &&
+            os_get_random((u8 *) &r, sizeof(r)) >= 0)
+        dur += r % (ssid->auth_failures * 10);

     os_get_reltime(&now);
     if (now.sec + dur <= ssid->disabled_until.sec)
-- 
2.5.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-Switch-from-using-os_random-to-using-os_get_random-..patch
Type: text/x-patch
Size: 1532 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/hostap/attachments/20160214/15113a98/attachment-0001.bin>


More information about the Hostap mailing list