diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2017-02-28 19:18:43 +0100 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2017-02-28 14:02:37 -0500 |
commit | 957e8db38f27932d353e86e9aa69cf16778b18f1 (patch) | |
tree | e6238772aab3a0a5b928fa56eaec343d1553c36c /os | |
parent | d7ac755f0b618eb1259d93c8a16ec6e39a18627c (diff) |
Use arc4random_buf(3) if available to generate cookies.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Diffstat (limited to 'os')
-rw-r--r-- | os/auth.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -45,6 +45,9 @@ from The Open Group. #ifdef WIN32 #include <X11/Xw32defs.h> #endif +#ifdef HAVE_LIBBSD +#include <bsd/stdlib.h> /* for arc4random_buf() */ +#endif struct protocol { unsigned short name_length; @@ -303,11 +306,15 @@ GenerateAuthorization(unsigned name_length, void GenerateRandomData(int len, char *buf) { +#ifdef HAVE_ARC4RANDOMBUF + arc4random_buf(buf, len); +#else int fd; fd = open("/dev/urandom", O_RDONLY); read(fd, buf, len); close(fd); +#endif } #endif /* XCSECURITY */ |