Skip to content

Commit

Permalink
Merge pull request #512 from ctrlaltf2/oob-fix
Browse files Browse the repository at this point in the history
Add bounds check to images loaded from bufferviews
  • Loading branch information
syoyo authored Jan 22, 2025
2 parents 1831424 + d530cd4 commit a5e653e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tiny_gltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -6453,6 +6453,15 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
return false;
}
const Buffer &buffer = model->buffers[size_t(bufferView.buffer)];
if (bufferView.byteOffset >= buffer.data.size()) {
if (err) {
std::stringstream ss;
ss << "image[" << idx << "] bufferView \"" << image.bufferView
<< "\" indexed out of bounds of its buffer." << std::endl;
(*err) += ss.str();
}
return false;
}

if (LoadImageData == nullptr) {
if (err) {
Expand Down

0 comments on commit a5e653e

Please sign in to comment.