The (marked safe) read_bytes function makes a call to the unsafe function libc::read. If read_bytes were to be called with a count value larger than the length of buf, the call to libc::read would be undefined behaviour and unsafe. All current callsites of read_bytes appear OK, but adding an assertion would ensure that all possible calls to read_bytes will be safe. If you would prefer to avoid a runtime assertion, I would suggest marking read_bytes as unsafe instead.
The (marked safe)
read_bytes
function makes a call to the unsafe functionlibc::read
. Ifread_bytes
were to be called with acount
value larger than the length ofbuf
, the call tolibc::read
would be undefined behaviour and unsafe. All current callsites ofread_bytes
appear OK, but adding an assertion would ensure that all possible calls toread_bytes
will be safe. If you would prefer to avoid a runtime assertion, I would suggest markingread_bytes
as unsafe instead.