Compare commits

...

6 Commits

Author SHA1 Message Date
Pichas f4c7606faf
fix no_valid_proc (#5774)
Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2024-09-16 09:17:22 +02:00
Kim Kulling 66187a77cf
Update dll_symbol.h (#5781)
- fix compile switch
- closes https://github.com/assimp/assimp/issues/5777
2024-09-15 20:44:32 +02:00
PatrickD 5c7acc968b
Fix naming in aiMaterial comment (#5780) 2024-09-13 14:24:09 +02:00
Lux f81ea6986c
Restored absolute transform calculation due to https://github.com/assimp/assimp/pull/5349 which requires this now. (#5751) 2024-09-11 10:11:15 +02:00
dataisland ab12e8d8ba
Fix stack overflow (#5764)
Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2024-09-10 23:15:31 +02:00
dataisland 3bd98611d7
Fix buffer overflow in MD3Loader (#5763)
Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2024-09-10 22:10:36 +02:00
7 changed files with 32 additions and 10 deletions

View File

@ -312,6 +312,8 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
child->mParent = last_parent;
last_parent = child.mNode;
new_abs_transform *= child->mTransformation;
}
// attach geometry
@ -334,6 +336,8 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
postnode->mParent = last_parent;
last_parent = postnode.mNode;
new_abs_transform *= postnode->mTransformation;
}
} else {
// free the nodes we allocated as we don't need them

View File

@ -78,7 +78,15 @@ static constexpr aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Recursive parsing of LWS files
void LWS::Element::Parse(const char *&buffer, const char *end) {
namespace {
constexpr int MAX_DEPTH = 1000; // Define the maximum depth allowed
}
void LWS::Element::Parse(const char *&buffer, const char *end, int depth) {
if (depth > MAX_DEPTH) {
throw std::runtime_error("Maximum recursion depth exceeded in LWS::Element::Parse");
}
for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
// begin of a new element with children
@ -121,7 +129,7 @@ void LWS::Element::Parse(const char *&buffer, const char *end) {
// parse more elements recursively
if (sub) {
children.back().Parse(buffer, end);
children.back().Parse(buffer, end, depth + 1);
}
}
}

View File

@ -76,7 +76,7 @@ public:
std::list<Element> children;
//! Recursive parsing function
void Parse(const char *&buffer, const char *end);
void Parse(const char *&buffer, const char *end, int depth = 0);
};
#define AI_LWS_MASK (0xffffffff >> 4u)

View File

@ -724,6 +724,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
std::vector<unsigned char> mBuffer2(fileSize);
file->Read(&mBuffer2[0], 1, fileSize);
mBuffer = &mBuffer2[0];
const unsigned char* bufferEnd = mBuffer + fileSize;
pcHeader = (BE_NCONST MD3::Header *)mBuffer;
@ -749,9 +750,15 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Navigate to the list of surfaces
BE_NCONST MD3::Surface *pcSurfaces = (BE_NCONST MD3::Surface *)(mBuffer + pcHeader->OFS_SURFACES);
if ((const unsigned char*)pcSurfaces + sizeof(MD3::Surface) * pcHeader->NUM_SURFACES > bufferEnd) {
throw DeadlyImportError("MD3 surface headers are outside the file");
}
// Navigate to the list of tags
BE_NCONST MD3::Tag *pcTags = (BE_NCONST MD3::Tag *)(mBuffer + pcHeader->OFS_TAGS);
if ((const unsigned char*)pcTags + sizeof(MD3::Tag) * pcHeader->NUM_TAGS > bufferEnd) {
throw DeadlyImportError("MD3 tags are outside the file");
}
// Allocate output storage
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
@ -1026,6 +1033,10 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
for (unsigned int i = 0; i < pcHeader->NUM_TAGS; ++i, ++pcTags) {
aiNode *nd = pScene->mRootNode->mChildren[i] = new aiNode();
if ((const unsigned char*)pcTags + sizeof(MD3::Tag) > bufferEnd) {
throw DeadlyImportError("MD3 tag is outside the file");
}
nd->mName.Set((const char *)pcTags->NAME);
nd->mParent = pScene->mRootNode;

View File

@ -848,11 +848,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
break;
}
#ifdef ASSIMP_BUILD_DEBUG
#ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
continue;
#endif // no validation
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
if (pimpl->bExtraVerbose) {
ASSIMP_LOG_DEBUG("Verbose Import: re-validating data structures");
@ -864,6 +860,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
break;
}
}
#endif // no validation
#endif // ! DEBUG
}
pimpl->mProgressHandler->UpdatePostProcess( static_cast<int>(pimpl->mPostProcessingSteps.size()),
@ -939,6 +936,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
profiler->EndRegion( "postprocess" );
}
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
if ( pimpl->bExtraVerbose || requestValidation ) {
ASSIMP_LOG_DEBUG( "Verbose Import: revalidating data structures" );
@ -949,6 +947,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
ASSIMP_LOG_ERROR( "Verbose Import: failed to revalidate data structures" );
}
}
#endif // no validation
// clear any data allocated by post-process steps
pimpl->mPPShared->Clean();

View File

@ -31,7 +31,7 @@
#pragma once
#if defined(_WIN32)
#if defined(_MSC_VER)
# pragma warning( disable: 4273)
# define P2T_COMPILER_DLLEXPORT __declspec(dllexport)
# define P2T_COMPILER_DLLIMPORT __declspec(dllimport)

View File

@ -701,7 +701,7 @@ struct aiMaterialProperty {
* Material data is stored using a key-value structure. A single key-value
* pair is called a 'material property'. C++ users should use the provided
* member functions of aiMaterial to process material properties, C users
* have to stick with the aiMaterialGetXXX family of unbound functions.
* have to stick with the aiGetMaterialXXX family of unbound functions.
* The library defines a set of standard keys (AI_MATKEY_XXX).
*/
#ifdef __cplusplus