65 {
66 if (size < std::numeric_limits<int>::min() ||
67 size > std::numeric_limits<int>::max()) {
68 AERROR <<
"Size value greater than the range of int value.";
69 return false;
70 }
71 FileInputStream raw_input(
fd_,
static_cast<int>(size));
72 CodedInputStream coded_input(&raw_input);
73 CodedInputStream::Limit limit = coded_input.PushLimit(static_cast<int>(size));
74 if (!message->ParseFromCodedStream(&coded_input)) {
75 AERROR <<
"Parse section message failed.";
76 end_of_file_ = coded_input.ExpectAtEnd();
77 return false;
78 }
79 if (!coded_input.ConsumedEntireMessage()) {
80 AERROR <<
"Do not consumed entire message.";
81 return false;
82 }
83 coded_input.PopLimit(limit);
84 if (static_cast<int64_t>(message->ByteSizeLong()) != size) {
85 AERROR <<
"Message size is not consistent in section header"
86 << ", expect: " << size << ", actual: " << message->ByteSizeLong();
87 return false;
88 }
89 return true;
90}