Skip to content

Commit

Permalink
Add bounds check to images loaded from bufferviews
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltf2 committed Jan 21, 2025
1 parent 1831424 commit d530cd4
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 d530cd4

Please sign in to comment.