Skip to content

fix(filesystem): overflow-safe bounds check in IOMemReader::pread#5262

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-pread
Open

fix(filesystem): overflow-safe bounds check in IOMemReader::pread#5262
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-pread

Conversation

@lgritz

@lgritz lgritz commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

IOMemReader::pread guarded its memcpy with size + size_t(offset) > m_buf.size(). For a large or negative offset, that addition wraps around size_t and can compare as in-bounds, skipping both the error path and the size clamp, so the memcpy reads past (or before) the buffer.

Assisted-by: Claude Code / Claude Opus 4.8

IOMemReader::pread guarded its memcpy with `size + size_t(offset) >
m_buf.size()`. For a large or negative offset, that addition wraps around
size_t and can compare as in-bounds, skipping both the error path and the
size clamp, so the memcpy reads past (or before) the buffer.

Assisted-by: Claude Code / Claude Opus 4.8

Signed-off-by: Larry Gritz <lg@larrygritz.com>
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.

1 participant