Remove read limit of ReadBinaryProto.

PiperOrigin-RevId: 323619709
Change-Id: I2b21c8c83d62f5f21c892ddad93c9d5a162fe6cf
This commit is contained in:
Mangpo Phothilimthana 2020-07-28 11:47:43 -07:00 committed by TensorFlower Gardener
parent a912a8ed6c
commit dc3099c444

View File

@ -544,15 +544,7 @@ Status ReadBinaryProto(Env* env, const string& fname,
std::unique_ptr<RandomAccessFile> file;
TF_RETURN_IF_ERROR(env->NewRandomAccessFile(fname, &file));
std::unique_ptr<FileStream> stream(new FileStream(file.get()));
// TODO(jiayq): the following coded stream is for debugging purposes to allow
// one to parse arbitrarily large messages for MessageLite. One most likely
// doesn't want to put protobufs larger than 64MB on Android, so we should
// eventually remove this and quit loud when a large protobuf is passed in.
protobuf::io::CodedInputStream coded_stream(stream.get());
// Total bytes hard limit / warning limit are set to 1GB and 512MB
// respectively.
coded_stream.SetTotalBytesLimit(1024LL << 20, 512LL << 20);
if (!proto->ParseFromCodedStream(&coded_stream) ||
!coded_stream.ConsumedEntireMessage()) {