Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixed potential overflow in multiview vertex buffer validation #1855

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion vulkano/src/command_buffer/validity/vertex_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ pub(in super::super) fn check_vertex_buffers(
.max_multiview_instance_index
.unwrap_or(0);

if first_instance + instance_count > max_instance_index + 1 {
// The condition is somewhat convoluted to avoid integer overflows.
let out_of_range = first_instance > max_instance_index
|| (instance_count > 0 && instance_count - 1 > max_instance_index - first_instance);
if out_of_range {
return Err(CheckVertexBufferError::TooManyInstances {
instance_count,
max_instance_count: max_instance_index + 1, // TODO: this can overflow
Expand Down