Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,13 @@ Pipeline Deserializer::deserialize(std::istream &in) {
}

Pipeline Deserializer::deserialize(const std::vector<uint8_t> &data) {
// The accessors below chase offsets straight out of the buffer, so the
// buffer has to be structurally sound before we touch it. flatbuffers does
// not check that unless we ask; without this a malformed .hlpipe reads out
// of bounds (Finish() writes no file identifier, so verify without one).
flatbuffers::Verifier verifier(data.data(), data.size());
user_assert(verifier.VerifyBuffer<Serialize::Pipeline>())
<< "malformed serialized pipeline: failed flatbuffer verification\n";
const auto *pipeline_obj = Serialize::GetPipeline(data.data());
if (pipeline_obj == nullptr) {
user_warning << "deserialized pipeline is empty\n";
Expand Down Expand Up @@ -1573,6 +1580,9 @@ std::map<std::string, Parameter> Deserializer::deserialize_parameters(std::istre

std::map<std::string, Parameter> Deserializer::deserialize_parameters(const std::vector<uint8_t> &data) {
std::map<std::string, Parameter> external_parameters_by_name;
flatbuffers::Verifier verifier(data.data(), data.size());
user_assert(verifier.VerifyBuffer<Serialize::Pipeline>())
<< "malformed serialized pipeline: failed flatbuffer verification\n";
const auto *pipeline_obj = Serialize::GetPipeline(data.data());
if (pipeline_obj == nullptr) {
user_warning << "deserialized pipeline is empty\n";
Expand Down
Loading