This is an automated email from the git hooks/post-receive script.
rharwood pushed a commit to branch master
in repository gssproxy.
The following commit(s) were added to refs/heads/master by this push:
new 23c5215 Use getrandom() for picking xid initial offset
23c5215 is described below
commit 23c52157c932017bab359e296d7baa2f71239a70
Author: Simo Sorce <simo(a)redhat.com>
AuthorDate: Mon Mar 23 16:04:15 2020 -0400
Use getrandom() for picking xid initial offset
Although this place id not cryptgraphically relevant, there is no point
in not using a proper random value: we call into krb5, which uses
getrandom() as well.
Signed-off-by: Simo Sorce <simo(a)redhat.com>
[rharwood(a)redhat.com: Rewrote commit message]
Reviewed-by: Robbie Harwood <rharwood(a)redhat.com>
Merges: #255
---
src/client/gpm_common.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/client/gpm_common.c b/src/client/gpm_common.c
index 808f350..60b1fdc 100644
--- a/src/client/gpm_common.c
+++ b/src/client/gpm_common.c
@@ -9,6 +9,7 @@
#include <pthread.h>
#include <sys/epoll.h>
#include <fcntl.h>
+#include <sys/random.h>
#include <sys/timerfd.h>
#define FRAGMENT_BIT (1 << 31)
@@ -41,7 +42,9 @@ pthread_once_t gpm_init_once_control = PTHREAD_ONCE_INIT;
static void gpm_init_once(void)
{
pthread_mutexattr_t attr;
- unsigned int seedp;
+ char *buf = (char *)&gpm_global_ctx.next_xid;
+ size_t len = sizeof(gpm_global_ctx.next_xid);
+ size_t ret = 0;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
@@ -52,8 +55,9 @@ static void gpm_init_once(void)
gpm_global_ctx.epollfd = -1;
gpm_global_ctx.timerfd = -1;
- seedp = time(NULL) + getpid() + pthread_self();
- gpm_global_ctx.next_xid = rand_r(&seedp);
+ while(ret < len) {
+ ret += getrandom(buf + ret, len - ret, 0);
+ }
pthread_mutexattr_destroy(&attr);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by thread