diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-07-15 14:58:07 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-07-15 15:53:10 +0200 |
commit | 408cfd7a3afba0c5a2310c5cbcee581f57d9248c (patch) | |
tree | 14ae4e2fb5a19db3265317e8f723ea70acaf42d5 | |
parent | bcfb86e94e8c352c52097580dadd693870ba705e (diff) | |
download | gnutls-408cfd7a3afba0c5a2310c5cbcee581f57d9248c.tar.gz |
urandom: use st_ino and st_rdev to determine device uniqueness
-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 f297679002..5cb9e88042 100644 --- a/lib/nettle/rnd-common.c +++ b/lib/nettle/rnd-common.c @@ -138,7 +138,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; @@ -304,7 +305,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; @@ -321,7 +323,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"); |