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.
This commit is contained in:
Haakan Younes 2019-04-01 10:04:23 -04:00
parent b06f06148e
commit 0b86daa483

View File

@ -517,7 +517,8 @@ Status ReadBinaryProto(Env* env, const string& fname,
// respectively. // respectively.
coded_stream.SetTotalBytesLimit(1024LL << 20, 512LL << 20); 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()); TF_RETURN_IF_ERROR(stream->status());
return errors::DataLoss("Can't parse ", fname, " as binary proto"); return errors::DataLoss("Can't parse ", fname, " as binary proto");
} }