dawn.node: Check for OOB in setBindGroup's typed array variant.

Bug: dawn:1123
Change-Id: I9ded6c76d50183ff14158e573b2c1a36a1becb3a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85641
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Corentin Wallez 2022-04-04 12:22:52 +00:00 committed by Dawn LUCI CQ
parent 2d2ddc3f06
commit e56b5f1097
2 changed files with 32 additions and 0 deletions

View File

@ -84,6 +84,22 @@ namespace wgpu::binding {
return; return;
} }
if (dynamicOffsetsDataStart > dynamicOffsetsData.ElementLength()) {
Napi::RangeError::New(env,
"dynamicOffsetsDataStart is out of bound of dynamicOffsetData")
.ThrowAsJavaScriptException();
return;
}
if (dynamicOffsetsDataLength >
dynamicOffsetsData.ElementLength() - dynamicOffsetsDataStart) {
Napi::RangeError::New(env,
"dynamicOffsetsDataLength + dynamicOffsetsDataStart is out of "
"bound of dynamicOffsetData")
.ThrowAsJavaScriptException();
return;
}
enc_.SetBindGroup(index, bg, dynamicOffsetsDataLength, enc_.SetBindGroup(index, bg, dynamicOffsetsDataLength,
dynamicOffsetsData.Data() + dynamicOffsetsDataStart); dynamicOffsetsData.Data() + dynamicOffsetsDataStart);
} }

View File

@ -119,6 +119,22 @@ namespace wgpu::binding {
return; return;
} }
if (dynamicOffsetsDataStart > dynamicOffsetsData.ElementLength()) {
Napi::RangeError::New(env,
"dynamicOffsetsDataStart is out of bound of dynamicOffsetData")
.ThrowAsJavaScriptException();
return;
}
if (dynamicOffsetsDataLength >
dynamicOffsetsData.ElementLength() - dynamicOffsetsDataStart) {
Napi::RangeError::New(env,
"dynamicOffsetsDataLength + dynamicOffsetsDataStart is out of "
"bound of dynamicOffsetData")
.ThrowAsJavaScriptException();
return;
}
enc_.SetBindGroup(index, bg, dynamicOffsetsDataLength, enc_.SetBindGroup(index, bg, dynamicOffsetsDataLength,
dynamicOffsetsData.Data() + dynamicOffsetsDataStart); dynamicOffsetsData.Data() + dynamicOffsetsDataStart);
} }