From 2acbbed9c111e4bd4272419fe31c2bdccdab0851 Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@lugatech.com>
Date: Tue, 9 Feb 2016 16:18:39 +0000
Subject: [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. 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@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(-)
@@ -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
@@ -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;
@@ -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 */
@@ -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;
@@ -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
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@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(-)