mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Merge branch 'getrandom' of https://github.com/MaxKellermann/zeek
- Removed the superfluous check for C++17 in the merge since that's a requirement enforced at the CMake-level. * 'getrandom' of https://github.com/MaxKellermann/zeek: util: use getrandom() on Linux if available
This commit is contained in:
commit
83874fa5fa
3 changed files with 24 additions and 1 deletions
8
CHANGES
8
CHANGES
|
@ -1,4 +1,12 @@
|
|||
|
||||
3.1.0-dev.406 | 2020-01-28 12:42:25 -0800
|
||||
|
||||
* util: use getrandom() on Linux if available (Max Kellermann)
|
||||
|
||||
Unlike /dev/urandom, getrandom() doesn't need a file descriptor and
|
||||
works when there is no /dev. It requires Linux 3.17 and glibc 2.25,
|
||||
but there is a fallback to the old code.
|
||||
|
||||
3.1.0-dev.403 | 2020-01-24 15:15:04 -0800
|
||||
|
||||
* Fixed decompose_uri() errors on URIs with empty port component (Frerich Raabe)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
3.1.0-dev.403
|
||||
3.1.0-dev.406
|
||||
|
|
15
src/util.cc
15
src/util.cc
|
@ -55,6 +55,13 @@
|
|||
|
||||
#include "3rdparty/doctest.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#if __has_include(<sys/random.h>)
|
||||
#define HAVE_GETRANDOM
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TEST_CASE("util extract_ip")
|
||||
{
|
||||
CHECK(extract_ip("[1.2.3.4]") == "1.2.3.4");
|
||||
|
@ -1035,6 +1042,14 @@ void init_random_seed(const char* read_file, const char* write_file)
|
|||
seeds_done = true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETRANDOM
|
||||
if ( ! seeds_done )
|
||||
{
|
||||
ssize_t nbytes = getrandom(buf, sizeof(buf), 0);
|
||||
seeds_done = nbytes == ssize_t(sizeof(buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( ! seeds_done )
|
||||
{
|
||||
// Gather up some entropy.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue