From ffadb3969f7e739ad3f8ccde67508f065d154fd1 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 28 Aug 2015 15:39:49 -0400 Subject: [PATCH] fread returns a size_t, not int. Change-Id: I305fd40a887b1dedf23eeddfb5231fc61b355ea8 Reviewed-on: https://boringssl-review.googlesource.com/5762 Reviewed-by: Adam Langley --- crypto/bio/file.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crypto/bio/file.c b/crypto/bio/file.c index cef33b66..2d3ccfea 100644 --- a/crypto/bio/file.c +++ b/crypto/bio/file.c @@ -182,20 +182,19 @@ static int file_free(BIO *bio) { } static int file_read(BIO *b, char *out, int outl) { - int ret = 0; - if (!b->init) { return 0; } - ret = fread(out, 1, outl, (FILE *)b->ptr); + size_t ret = fread(out, 1, outl, (FILE *)b->ptr); if (ret == 0 && ferror((FILE *)b->ptr)) { OPENSSL_PUT_SYSTEM_ERROR(fread); OPENSSL_PUT_ERROR(BIO, ERR_R_SYS_LIB); - ret = -1; + return -1; } - return ret; + /* fread reads at most |outl| bytes, so |ret| fits in an int. */ + return (int)ret; } static int file_write(BIO *b, const char *in, int inl) {