Skip to content

Commit

Permalink
Merge pull request assimp#4211 from ms-maxvollmer/ms-maxvollmer/crash…
Browse files Browse the repository at this point in the history
…fixes2

Added checks for out of bounds data access/writing
  • Loading branch information
kimkulling authored Nov 30, 2021
2 parents 745f5e7 + d6f3f29 commit cc05b4c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code/AssetLib/glTF/glTFCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class Ref {

inline unsigned int GetIndex() const { return index; }

operator bool() const { return vector != 0; }
operator bool() const { return vector != nullptr && index < vector->size(); }

T *operator->() { return (*vector)[index]; }

Expand Down
4 changes: 4 additions & 0 deletions code/AssetLib/glTF2/glTF2Asset.inl
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ inline void Buffer::Read(Value &obj, Asset &r) {
inline bool Buffer::LoadFromStream(IOStream &stream, size_t length, size_t baseOffset) {
byteLength = length ? length : stream.FileSize();

if (byteLength > stream.FileSize()) {
throw DeadlyImportError("GLTF: Invalid byteLength exceeds size of actual data.");
}

if (baseOffset) {
stream.Seek(baseOffset, aiOrigin_SET);
}
Expand Down
4 changes: 3 additions & 1 deletion include/assimp/Vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ class Vertex {
/** Extract a particular vertex from a anim mesh and interleave all components */
explicit Vertex(const aiAnimMesh* msh, unsigned int idx) {
ai_assert(idx < msh->mNumVertices);
position = msh->mVertices[idx];
if (msh->HasPositions()) {
position = msh->mVertices[idx];
}

if (msh->HasNormals()) {
normal = msh->mNormals[idx];
Expand Down

0 comments on commit cc05b4c

Please sign in to comment.