Skip to content

fix: reject truncated encoded integers - #439

Open
wesen wants to merge 1 commit into
blevesearch:masterfrom
wesen:task/memuvarint-truncated-eof
Open

fix: reject truncated encoded integers#439
wesen wants to merge 1 commit into
blevesearch:masterfrom
wesen:task/memuvarint-truncated-eof

Conversation

@wesen

@wesen wesen commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Return io.ErrUnexpectedEOF when memUvarintReader reaches the end of its
input after reading a continuation byte.

The reader previously checked for empty input only before entering its decode
loop. If the final available byte had its continuation bit set, the next loop
iteration indexed beyond the slice and panicked.

Change

  • check the cursor before each in-loop slice access;
  • preserve the consumed cursor position on truncation;
  • add regression cases containing one and multiple continuation bytes.

Validation

go test ./...

Additional resources

If you are willing to endure some slop writing, this is how I/the llm encountered the issue: https://parc.yolo.scapegoat.dev/note/projects/2026/07/28/project-report-zapx-defensive-varint-decoding-for-corrupt-bleve-postings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants