Repository navigation
Reject truncated GGUF tensor data in split and export tools - #30497
Merged
ggerganov merged 2 commits intoOct 19, 2026
Merged
Conversation
…pted tensor output when the input GGUF file is truncated. The fix is to add tensor-data bounds checks and short-read checks in gguf-split.cpp and export-lora.cpp, and a regression test that checks truncated input is rejected and valid tensor data is preserved.#
Member
|
Why the seeking when you can just check the state of the stream? Also, drop the tests please. |
…e input GGUF file is truncated. Fix : add short-read checks in gguf-split.cpp (in copy_file_to_file in split_strategy) and export-lora.cpp (in read_tensor_data of file_input) so that truncated input is rejected.
CISC
approved these changes
Oct 15, 2026
Contributor
Author
|
I have removed the seeking and the changes made in tests.sh while keeping the short-read checks by checking the stream state. |
edwardyoon
pushed a commit
to edwardyoon/focus-llama
that referenced
this pull request
Oct 24, 2026
…gml-org#30497) * The problem here in the repo is gguf-split can silently produce corrupted tensor output when the input GGUF file is truncated. The fix is to add tensor-data bounds checks and short-read checks in gguf-split.cpp and export-lora.cpp, and a regression test that checks truncated input is rejected and valid tensor data is preserved.# * Bug : GGUF-split can silently produce corrupted tensor output when the input GGUF file is truncated. Fix : add short-read checks in gguf-split.cpp (in copy_file_to_file in split_strategy) and export-lora.cpp (in read_tensor_data of file_input) so that truncated input is rejected.
auRose94
pushed a commit
to auRose94/llama.cpp
that referenced
this pull request
Oct 28, 2026
…gml-org#30497) * The problem here in the repo is gguf-split can silently produce corrupted tensor output when the input GGUF file is truncated. The fix is to add tensor-data bounds checks and short-read checks in gguf-split.cpp and export-lora.cpp, and a regression test that checks truncated input is rejected and valid tensor data is preserved.# * Bug : GGUF-split can silently produce corrupted tensor output when the input GGUF file is truncated. Fix : add short-read checks in gguf-split.cpp (in copy_file_to_file in split_strategy) and export-lora.cpp (in read_tensor_data of file_input) so that truncated input is rejected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This change addresses incorrect tensor data handling when a GGUF file is truncated or its tensor data extends beyond the end of the file.
In gguf-split, the requested tensor data could be read incompletely without the short read being detected. Since the read buffer is reused, the remaining bytes could contain data from a previous tensor, resulting in corrupted output without the expected error.
The changes add bounds validation for tensor data in gguf-split and export-lora, along with checks to detect incomplete reads. A regression test creates a small GGUF file containing two tensors, truncates the file before the second tensor's data, and verifies that the tool rejects the input. It also checks that splitting the valid file preserves the expected tensor data.
Additional information
NA
Requirements
AI assistance covered investigating the truncated-GGUF issue, analyzing the cause of the unchecked reads, proposing the bounds-check implementation, and developing the regression test.
I applied the patch, built the affected tools, ran the regression tests, reviewed the Git diff, and submitted the changes.