Skip to content

fix: correct seek overflow and sign bugs in BufStream and StreamSlice - #62

Merged
bugadani merged 3 commits into
masterfrom
fix/seek-bugs-rebased
Oct 23, 2026
Merged

bugadani merged 3 commits into
masterfrom
fix/seek-bugs-rebased

Conversation

@MabezDev

@MabezDev MabezDev commented May 1, 2026 •

Copy link
Copy Markdown
Owner
  • Fix SeekFrom::End sign in BufStream.
  • Do seek arithmetic in i128 in BufStream and StreamSlice. Return InvalidSeek for a target before 0 or past the limit.
  • Run block-device-adapters tests in CI.

@MabezDev
MabezDev force-pushed the fix/seek-bugs-rebased branch 7 times, most recently from be13d63 to 7106d56 Compare May 1, 2026 17:32
Comment thread block-device-adapters/src/buf_stream.rs Outdated
.ok()
.and_then(|o| o.checked_add(x))
.map(|o| o.max(0) as u64)
.unwrap_or(0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if silently not seeking is the right behaviour on overflow, maybe we should instead return an error.

Comment thread block-device-adapters/src/buf_stream.rs Outdated
SeekFrom::Current(x) => (self.current_offset as i64 + x) as u64,
SeekFrom::End(x) => {
let size = self.inner.size().await? as i64;
(size + x).max(0) as u64

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is saturating at 0 actually a meaningful thing to do? Could we return an error instead?

@bugadani
bugadani force-pushed the fix/seek-bugs-rebased branch from 7106d56 to 974a17d Compare October 23, 2026 18:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bugadani
bugadani merged commit b7fab57 into master Oct 23, 2026
4 checks passed
@bugadani
bugadani deleted the fix/seek-bugs-rebased branch October 23, 2026 18:53
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