From e9293e7622f54cfaff942362757d537e18a4701f Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@lugatech.com>
Date: Sun, 14 Feb 2016 14:02:19 +0000
Subject: [PATCH 09/10] 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@lugatech.com>
---
wpa_supplicant/wpa_supplicant.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
@@ -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