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

Prevent a few integer overflows #5042

Merged
merged 3 commits into from
Jan 12, 2024
Merged

Prevent a few integer overflows #5042

merged 3 commits into from
Jan 12, 2024

Conversation

nical
Copy link
Contributor

@nical nical commented Jan 11, 2024

Connections

Found while running the CTS in Firefox.

Description

We have a few places with the following pattern:

let last_foo = first_foo + foo_count;
if last_foo > foo_limit {
   // error ...
}

With the addition in the first line vulnerable to integer overflows. This PR addresses it by making sure that the limit is always smaller than u32::MAX and using saturating_add so that cases that would have overflown are treated as errors.

Testing

Covered by the CTS.

Checklist

  • Run cargo fmt.
  • Run cargo clippy.
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@nical nical requested a review from a team as a code owner January 11, 2024 10:58
CHANGELOG.md Show resolved Hide resolved
wgpu-core/src/command/render.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/render.rs Outdated Show resolved Hide resolved
@cwfitzgerald cwfitzgerald enabled auto-merge (squash) January 12, 2024 15:01
@cwfitzgerald cwfitzgerald merged commit 11c29c8 into gfx-rs:trunk Jan 12, 2024
27 checks passed
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.

4 participants