Check fread's return value in tool/server.cc.
Some compilers complain and it's worth checking. Maybe the file changed in size
between ftell and fread.
Change-Id: I7898b8517556ec6899bd6e8866ba3d1cd7efd5f4
Reviewed-on: https://boringssl-review.googlesource.com/5763
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/tool/server.cc b/tool/server.cc
index 69994bc..abc71cf 100644
--- a/tool/server.cc
+++ b/tool/server.cc
@@ -46,6 +46,7 @@
static bool LoadOCSPResponse(SSL_CTX *ctx, const char *filename) {
void *data = NULL;
bool ret = false;
+ size_t bytes_read;
long length;
FILE *f = fopen(filename, "rb");
@@ -66,9 +67,10 @@
}
rewind(f);
- fread(data, 1, length, f);
+ bytes_read = fread(data, 1, length, f);
if (ferror(f) != 0 ||
- !SSL_CTX_set_ocsp_response(ctx, (uint8_t*)data, length)) {
+ bytes_read != (size_t)length ||
+ !SSL_CTX_set_ocsp_response(ctx, (uint8_t*)data, bytes_read)) {
goto out;
}