[PATCH 10/10] Remove os_random() as it makes use of a weak PRNG, having previously refactored all its callers to use os_get_random(…) instead

Nick Lowe nick.lowe at lugatech.com
Sun Feb 14 11:43:06 PST 2016


Remove os_random() as it makes use of a weak PRNG, having previously
refactored all its callers to use os_get_random(…) instead. We should
avoid using this outright unless there is a compelling performance
justification to retain it. Such a justification does not exist for
the hostapd/wpa_supplicant. When marginal, insignificant performance
gains are equated against the benefit of removing a function that can
be subtly dangerous, we should err on the side of caution.

Signed-off-by: Nick Lowe <nick.lowe at lugatech.com>
---
 src/utils/os.h          | 6 ------
 src/utils/os_internal.c | 6 ------
 src/utils/os_none.c     | 6 ------
 src/utils/os_unix.c     | 6 ------
 src/utils/os_win32.c    | 7 -------
 5 files changed, 31 deletions(-)

diff --git a/src/utils/os.h b/src/utils/os.h
index 9e496fb..08c97e0 100644
--- a/src/utils/os.h
+++ b/src/utils/os.h
@@ -165,12 +165,6 @@ void os_daemonize_terminate(const char *pid_file);
 int os_get_random(unsigned char *buf, size_t len);

 /**
- * os_random - Get pseudo random value (not necessarily very strong)
- * Returns: Pseudo random value
- */
-unsigned long os_random(void);
-
-/**
  * os_rel2abs_path - Get an absolute path for a file
  * @rel_path: Relative path to a file
  * Returns: Absolute path for the file or %NULL on failure
diff --git a/src/utils/os_internal.c b/src/utils/os_internal.c
index ed6eb3c..06b4e7f 100644
--- a/src/utils/os_internal.c
+++ b/src/utils/os_internal.c
@@ -139,12 +139,6 @@ int os_get_random(unsigned char *buf, size_t len)
 }


-unsigned long os_random(void)
-{
-    return random();
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
     char *buf = NULL, *cwd, *ret;
diff --git a/src/utils/os_none.c b/src/utils/os_none.c
index 0c3214d..523292f 100644
--- a/src/utils/os_none.c
+++ b/src/utils/os_none.c
@@ -61,12 +61,6 @@ int os_get_random(unsigned char *buf, size_t len)
 }


-unsigned long os_random(void)
-{
-    return 0;
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
     return NULL; /* strdup(rel_path) can be used here */
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 8f8dc5b..3ae5f8f 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -266,12 +266,6 @@ int os_get_random(unsigned char *buf, size_t len)
 }


-unsigned long os_random(void)
-{
-    return random();
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
     char *buf = NULL, *cwd, *ret;
diff --git a/src/utils/os_win32.c b/src/utils/os_win32.c
index dea27b9..6adcaf0 100644
--- a/src/utils/os_win32.c
+++ b/src/utils/os_win32.c
@@ -144,13 +144,6 @@ int os_get_random(unsigned char *buf, size_t len)
     return ret ? 0 : -1;
 }

-
-unsigned long os_random(void)
-{
-    return rand();
-}
-
-
 char * os_rel2abs_path(const char *rel_path)
 {
     return _strdup(rel_path);
-- 
2.5.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0010-Remove-os_random-as-it-makes-use-of-a-weak-PRNG-havi.patch
Type: text/x-patch
Size: 2951 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/hostap/attachments/20160214/163ae739/attachment.bin>


More information about the Hostap mailing list