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>
This commit is contained in:
David Benjamin 2015-08-28 15:43:26 -04:00 committed by Adam Langley
parent ffadb3969f
commit ed50cee007

View File

@ -46,6 +46,7 @@ static const struct argument kArguments[] = {
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 @@ static bool LoadOCSPResponse(SSL_CTX *ctx, const char *filename) {
}
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;
}