mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
avoid fork-unsafe arc4random implementations
Some old implementaions of arc4random_buf(3) were ARC4 based, or unsafe when forked, or both. Resort to /dev/urandom for those known problematic cases. Fix [Bug #15039] Patch from Thomas Hurst <tom@hur.st> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
183ac396d4
commit
b120f5e38d
1 changed files with 6 additions and 0 deletions
6
random.c
6
random.c
|
@ -494,8 +494,14 @@ fill_random_bytes_syscall(void *seed, size_t size, int unused)
|
|||
static int
|
||||
fill_random_bytes_syscall(void *buf, size_t size, int unused)
|
||||
{
|
||||
#if (defined(__OpenBSD__) && OpenBSD >= 201411) || \
|
||||
(defined(__NetBSD__) && __NetBSD_Version__ >= 700000000) || \
|
||||
(defined(__FreeBSD__) && __FreeBSD_version >= 1200079)
|
||||
arc4random_buf(buf, size);
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue