From 0b86daa4831d33b6d3cfcc3128d078c6aa04bb9f Mon Sep 17 00:00:00 2001 From: Haakan Younes Date: Mon, 1 Apr 2019 10:04:23 -0400 Subject: [PATCH] Read full message in ReadBinaryProto(). Add call to coded_stream.ConsumedEntireMessage() in ReadBinaryProto() to ensure that full message is read, and that ReadBinaryProto() does not report success on a partial read. --- tensorflow/core/platform/env.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/platform/env.cc b/tensorflow/core/platform/env.cc index 59768bf92ae..1037b2b918b 100644 --- a/tensorflow/core/platform/env.cc +++ b/tensorflow/core/platform/env.cc @@ -517,7 +517,8 @@ Status ReadBinaryProto(Env* env, const string& fname, // respectively. coded_stream.SetTotalBytesLimit(1024LL << 20, 512LL << 20); - if (!proto->ParseFromCodedStream(&coded_stream)) { + if (!proto->ParseFromCodedStream(&coded_stream) || + !coded_stream.ConsumedEntireMessage()) { TF_RETURN_IF_ERROR(stream->status()); return errors::DataLoss("Can't parse ", fname, " as binary proto"); }