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

Prevent out-of-range memory writes by sparse accessors
kimkulling-remove_deprecated_data
Kim Kulling 2021-11-26 09:02:17 +01:00 committed by GitHub
commit da8772c57b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -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;