From 0ef7bfd59c0a97b39b2e1152da30db4e96e3a915 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 16 Jan 2019 13:05:34 -0800 Subject: [PATCH] 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 --- Utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils.cpp b/Utils.cpp index 4464afc..f00d168 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -377,7 +377,7 @@ status_t ReadRandomBytes(size_t bytes, char* buf) { return -errno; } - size_t n; + ssize_t n; while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], bytes))) > 0) { bytes -= n; buf += n;