The fread(3) function only returns the number of bytes read if size=1. Instead, this function is used with the file length as size, and nmemb=1, in which case it returns the number of elements read, not their length. So it will return "1" if at least size bytes were read, so we should be expecting that. Signed-off-by: Patrick Uiterwijk <patrick@xxxxxxxxxxxxxx> --- src/evmctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evmctl.c b/src/evmctl.c index b02be8b..5a5afc5 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -205,7 +205,7 @@ static unsigned char *file2bin(const char *file, const char *ext, int *size) fclose(fp); return NULL; } - if (fread(data, len, 1, fp) != len) { + if (fread(data, len, 1, fp) != 1) { log_err("Failed to fread %zu bytes: %s\n", len, name); fclose(fp); free(data); -- 2.24.1