[PATCH 05/10] Switch from using os_random() to using os_get_random(...) in ap_handle_timer(...)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Switch from using os_random() to using
 os_get_random(...) in ap_handle_timer(...) 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@xxxxxxxxxxxx>
---
 src/ap/sta_info.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index 3d7c839..50737fd 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -378,7 +378,10 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
          * all stations at the same time if we have lots of associated
          * stations that are idle (but keep re-associating).
          */
-        int fuzz = os_random() % 20;
+        int fuzz = 0;
+        if (os_get_random((u8 *) &fuzz, sizeof(fuzz)) >= 0)
+            fuzz = fuzz % 20;
+
         inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
         if (inactive_sec == -1) {
             wpa_msg(hapd->msg_ctx, MSG_DEBUG,
-- 
2.5.0
From 4c3ec9dbf6e083cc3270ab976b5cce4e936830ef Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
Date: Tue, 9 Feb 2016 16:05:12 +0000
Subject: [PATCH 05/10] Switch from using os_random() to using
 os_get_random(...) in ap_handle_timer(...) 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@xxxxxxxxxxxx>
---
 src/ap/sta_info.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index 3d7c839..50737fd 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -378,7 +378,10 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
 		 * all stations at the same time if we have lots of associated
 		 * stations that are idle (but keep re-associating).
 		 */
-		int fuzz = os_random() % 20;
+		int fuzz = 0;
+		if (os_get_random((u8 *) &fuzz, sizeof(fuzz)) >= 0)
+			fuzz = fuzz % 20;
+
 		inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
 		if (inactive_sec == -1) {
 			wpa_msg(hapd->msg_ctx, MSG_DEBUG,
-- 
2.5.0

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux