Skip to content

Commit 776cf74

Browse files
committed
random-util: if zero random bytes are requested we can always fulfill the request
1 parent 6853434 commit 776cf74

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/basic/random-util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ int genuine_random_bytes(void *p, size_t n, RandomFlags flags) {
7676
* the random pool is fully initialized or not. Otherwise, it will return success if at least some random
7777
* bytes were successfully acquired, and an error if the kernel has no entropy whatsover for us. */
7878

79+
if (n == 0)
80+
return 0;
81+
7982
/* Use the getrandom() syscall unless we know we don't have it. */
8083
if (have_syscall != 0 && !HAS_FEATURE_MEMORY_SANITIZER) {
8184

0 commit comments

Comments
 (0)