mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
urandom: Fail if /dev/urandom returns EOF.
This is an unexpected error, so fail hard instead of leaking End_of_file exception. Nothing that calls into the Urandom module expects or handles End_of_file.
This commit is contained in:
@@ -27,13 +27,14 @@
|
||||
open Unix
|
||||
|
||||
open Std_utils
|
||||
open Tools_utils
|
||||
open Common_gettext.Gettext
|
||||
|
||||
let read_byte fd =
|
||||
let b = Bytes.make 1 ' ' in
|
||||
fun () ->
|
||||
if read fd b 0 1 = 0 then (
|
||||
raise End_of_file
|
||||
);
|
||||
if read fd b 0 1 = 0 then
|
||||
error (f_"unexpected end of file while reading /dev/urandom");
|
||||
Char.code (Bytes.unsafe_get b 0)
|
||||
|
||||
let urandom_bytes n =
|
||||
|
||||
Reference in New Issue
Block a user