Skip to content

Commit 85b3085

Browse files
committed
Fix segmentation fault on missing file
1 parent d132926 commit 85b3085

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

randombytes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ static int randombytes_linux_wait_for_entropy(int device)
174174
strategy = PROC;
175175
// Open the entropy count file
176176
proc_file = fopen("/proc/sys/kernel/random/entropy_avail", "r");
177+
if (proc_file == NULL) {
178+
return -1;
179+
}
177180
} else if (retcode != 0) {
178181
// Unrecoverable ioctl error
179182
return -1;

0 commit comments

Comments
 (0)