Просмотр исходного кода

Merge pull request #4207 from jakrams/msft-jakras-fix-corrupted-accessor

Prevent out-of-range memory writes by sparse accessors
Kim Kulling 3 лет назад
Родитель
Сommit
da8772c57b
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      code/AssetLib/glTF2/glTF2Asset.inl

+ 5 - 0
code/AssetLib/glTF2/glTF2Asset.inl

@@ -809,6 +809,11 @@ inline void Accessor::Sparse::PatchData(unsigned int elementSize) {
         }
         }
 
 
         offset *= elementSize;
         offset *= elementSize;
+
+        if (offset + elementSize > data.size()) {
+            throw DeadlyImportError("Invalid sparse accessor. Byte offset for patching points outside allocated memory.");
+        }
+
         std::memcpy(data.data() + offset, pValues, elementSize);
         std::memcpy(data.data() + offset, pValues, elementSize);
 
 
         pValues += elementSize;
         pValues += elementSize;