Utils: correctly handle read() errors in ReadRandomBytes()

read() returns -1 on error, so we need to use a signed type.

Test: Booted device with FDE
Change-Id: Ib44247c1cdfd38674a7439209e333823f2fb6cf8
gugelfrei
Eric Biggers 6 years ago
parent 9f7aa175a0
commit 0ef7bfd59c

@ -377,7 +377,7 @@ status_t ReadRandomBytes(size_t bytes, char* buf) {
return -errno; return -errno;
} }
size_t n; ssize_t n;
while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], bytes))) > 0) { while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], bytes))) > 0) {
bytes -= n; bytes -= n;
buf += n; buf += n;

Loading…
Cancel
Save