projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6853434
)
random-util: if zero random bytes are requested we can always fulfill the request
author
Lennart Poettering
<lennart@poettering.net>
Wed, 7 Nov 2018 18:14:47 +0000
(19:14 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Thu, 8 Nov 2018 08:44:27 +0000
(09:44 +0100)
src/basic/random-util.c
patch
|
blob
|
history
diff --git
a/src/basic/random-util.c
b/src/basic/random-util.c
index
1c54b07
..
922b5a5
100644
(file)
--- 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) {