Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
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
7 changes: 7 additions & 0 deletions engine/config/gguf_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ std::pair<std::size_t, std::string> GGUFHandler::ReadString(
uint64_t length;
std::memcpy(&length, data_ + offset, sizeof(uint64_t));

if (offset + 8 + length > file_size_) {
throw std::runtime_error("GGUF metadata string length exceeds file size.\n");
}

std::string value(reinterpret_cast<const char*>(data_ + offset + 8), length);
return {8 + static_cast<std::size_t>(length), value};
}
Expand Down Expand Up @@ -274,6 +278,9 @@ size_t GGUFHandler::ReadArray(std::size_t offset, const std::string& key) {
}

array_offset += length;
if (offset + array_offset > file_size_) {
throw std::runtime_error("GGUF Parser Array exceeded file size.\n");
}
}
if (array_values_string.size() > 0)
metadata_array_string_[key] = array_values_string;
Expand Down
Loading