diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-07-15 14:58:07 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-07-15 14:58:07 +0200 |
commit | 9eec50904ca77341de57785b652caee497253ca6 (patch) | |
tree | 4a7544a70f75a9e3ecd0c9fdf5b73c8935f6a78c | |
parent | 4061f56129449bf66a93fa6faf059c47a947659c (diff) | |
download | gnutls-getrandom.tar.gz |
urandom: use st_ino and st_rdev to determine device uniquenessgetrandom
-rw-r--r-- | lib/nettle/rnd-common.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/nettle/rnd-common.c b/lib/nettle/rnd-common.c index 0c27a1e3aa..a92c9c40ac 100644 --- a/lib/nettle/rnd-common.c +++ b/lib/nettle/rnd-common.c @@ -137,7 +137,8 @@ void _rnd_system_entropy_deinit(void) #include "egd.h" static int _gnutls_urandom_fd = -1; -static mode_t _gnutls_urandom_fd_mode = 0; +static ino_t _gnutls_urandom_fd_ino = 0; +static dev_t _gnutls_urandom_fd_rdev = 0; get_entropy_func _rnd_get_system_entropy = NULL; @@ -272,7 +273,7 @@ int _rnd_system_entropy_check(void) return 0; ret = fstat(_gnutls_urandom_fd, &st); - if (ret < 0 || st.st_mode != _gnutls_urandom_fd_mode) { + if (ret < 0 || st.st_ino != _gnutls_urandom_fd_ino || st.st_rdev != _gnutls_urandom_fd_rdev) { return _rnd_system_entropy_init(); } return 0; @@ -302,7 +303,8 @@ int _rnd_system_entropy_init(void) fcntl(_gnutls_urandom_fd, F_SETFD, old | FD_CLOEXEC); if (fstat(_gnutls_urandom_fd, &st) >= 0) { - _gnutls_urandom_fd_mode = st.st_mode; + _gnutls_urandom_fd_ino = st.st_ino; + _gnutls_urandom_fd_rdev = st.st_rdev; } _rnd_get_system_entropy = _rnd_get_system_entropy_urandom; @@ -319,7 +321,8 @@ fallback: } if (fstat(_gnutls_urandom_fd, &st) >= 0) { - _gnutls_urandom_fd_mode = st.st_mode; + _gnutls_urandom_fd_ino = st.st_ino; + _gnutls_urandom_fd_rdev = st.st_rdev; } _gnutls_debug_log("EGD random generator was detected\n"); |