Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate that a binding offset fits in the buffer #5027

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

nical
Copy link
Contributor

@nical nical commented Jan 9, 2024

Connections

Crash found when running the CTS in Firefox.

Description

If the binding size is not specified we didn't validate that the offset was in the bounds of the buffer, causing an overflow panic on debug and UB/nonsense on release. This PR adds the missing validation.

Testing

Covered by the CTS

Checklist

  • Run cargo fmt.
  • Run cargo clippy.
  • Run cargo xtask test to run tests.

@nical nical requested a review from a team as a code owner January 9, 2024 13:55
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

Nice!

@teoxoy teoxoy merged commit 37755b6 into gfx-rs:trunk Jan 9, 2024
27 checks passed
if buffer.size < bb.offset {
return Err(Error::BindingRangeTooLarge {
buffer: bb.buffer_id,
range: bb.offset..bb.offset,
Copy link
Member

Choose a reason for hiding this comment

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

My only concern is that this faux range may make the error message very confusing for the user, as this range never actually shows up in their code.

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.

3 participants