diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-07 19:14:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-08 09:44:27 +0100 |
commit | 776cf7461fa54445a40df17c40cfd024b6f09578 (patch) | |
tree | dc8ee31ec59ea1dbecd9dcb408b4d6024a4abf17 /src | |
parent | 68534345b8af31e8df3d45cf21a832a42af52996 (diff) | |
download | systemd-776cf7461fa54445a40df17c40cfd024b6f09578.tar.gz systemd-776cf7461fa54445a40df17c40cfd024b6f09578.tar.bz2 systemd-776cf7461fa54445a40df17c40cfd024b6f09578.zip |
random-util: if zero random bytes are requested we can always fulfill the request
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/random-util.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/basic/random-util.c b/src/basic/random-util.c index 1c54b07fbb..922b5a57b0 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -76,6 +76,9 @@ int genuine_random_bytes(void *p, size_t n, RandomFlags flags) { * the random pool is fully initialized or not. Otherwise, it will return success if at least some random * bytes were successfully acquired, and an error if the kernel has no entropy whatsover for us. */ + if (n == 0) + return 0; + /* Use the getrandom() syscall unless we know we don't have it. */ if (have_syscall != 0 && !HAS_FEATURE_MEMORY_SANITIZER) { |