mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4536] [Engine] gguf_reader: header bounds check cannot wrap on a huge string length #5077
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5077
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4536
Author: @schmittcn
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:pr/gguf-cursor-overflow📝 Commits (1)
92ab610gguf_reader: the header bounds check cannot wrap (n > size - pos instead of pos + n > size)📊 Changes
2 files changed (+25 additions, -1 deletions)
View changed files
📝
include/strata/artifact/gguf_reader.hpp(+1 -1)📝
src/artifact/gguf_reader_test.cpp(+24 -0)📄 Description
Problem and result
Cursor::need()ininclude/strata/artifact/gguf_reader.hppcheckedpos_ + n > size_.nis a string length read from the file. When a GGUF header gives a length near 2^64,pos_ + nwraps to a small value, the check passes, andstr()goes on to build astd::stringof that length.Today that constructor throws
std::length_error, which is caught as a bad file, so nothing is read out of bounds. That is luck, not the check. The check is nown > size_ - pos_, which can't wrap (pos_ <= size_always holds). The same file is refused as "GGUF: unexpected end of file in header", like any other truncated header.Found by reading the code. Not seen with a real model file.
Validation
Revision:
upstream/mainat46c152a1, Linux, g++ (system).src/artifact/gguf_reader_test.cpp, a one-tensor header whose name length isUINT64_MAX - 15.g++ -std=c++20 -Iinclude src/artifact/gguf_reader_test.cpp(strata_artifactis header-only, an INTERFACE target).main: the new case reportsbasic_string::_M_createinstead of the truncated-header error, which shows the wrap.cmake -DSTRATA_BUILD_TESTS=ON, then a build ofgguf_reader_test,gguf_split_testandstrata-gguf, thenctest -R "gguf_(reader|split)_test": 2 of 2 passed.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.