Repository navigation
fix(file): reject reads that do not fit the result buffer - #114
Closed
cursor[bot] wants to merge 1 commit into
Closed
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
file_read returned success after clipping to the caller buffer. The agent passes a 4096-byte slot, so a later write_file could replace the file with that prefix and delete the rest. Co-authored-by: esadrianno <esadrianno@gmail.com>
Collaborator
|
Superseded by #120: consolidated into the operator-authored branch fix/file-read-bounds (same fix, re-validated with CI=true make test and make static). Closing in favor of the consolidation. |
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.
Bug and impact
file_readreturned success after clipping a file to the caller buffer.agent_runpasses a 4096-byte tool result slot. A workspace file of 4096 bytes or more (still under the 256 KiB hard cap) came back as a prefix with no error. A follow-upwrite_filereplaces the whole file, so an edit such as "add a title to notes.md" on an 8 KiB note deletes everything past the first 4095 bytes.Root cause
After the size check against
MAX_FILE_SIZE,file_readsetto_readtomax_len - 1and returned 0.Fix
If the file plus a trailing NUL does not fit in
max_len, return -1 and a JSON error that includes the byte size. A file that fits exactly still returns the full contents.Validation
make test_filefailed on the new regression (oversize read fails) before the fix and passed afterward (83 tests run, 0 failed).