Fix overflowing allocations in MDLMaterialLoader
Some allocations might underallocate due to integer overflows. This commit ensures that we are throwing an exception if the allocation size does not fit in an unsigned int. Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25341pull/4146/head
parent
30f17aa206
commit
932dfe0562
|
@ -132,6 +132,9 @@ void MDLImporter::CreateTextureARGB8_3DGS_MDL3(const unsigned char *szData) {
|
|||
pcNew->mWidth = pcHeader->skinwidth;
|
||||
pcNew->mHeight = pcHeader->skinheight;
|
||||
|
||||
if(pcNew->mWidth != 0 && pcNew->mHeight > UINT_MAX/pcNew->mWidth) {
|
||||
throw DeadlyImportError("Invalid MDL file. A texture is too big.");
|
||||
}
|
||||
pcNew->pcData = new aiTexel[pcNew->mWidth * pcNew->mHeight];
|
||||
|
||||
const unsigned char *szColorMap;
|
||||
|
@ -217,6 +220,9 @@ void MDLImporter::ParseTextureColorData(const unsigned char *szData,
|
|||
|
||||
// allocate storage for the texture image
|
||||
if (do_read) {
|
||||
if(pcNew->mWidth != 0 && pcNew->mHeight > UINT_MAX/pcNew->mWidth) {
|
||||
throw DeadlyImportError("Invalid MDL file. A texture is too big.");
|
||||
}
|
||||
pcNew->pcData = new aiTexel[pcNew->mWidth * pcNew->mHeight];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue