From 46d56ff6190c5923142e53d9cf108073c7be7b82 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sat, 13 Mar 2010 17:14:59 +0000 Subject: [PATCH] Change string validation to suit the new binary layout. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@607 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ValidateDataStructure.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index dc76ae225..f9a4a8b47 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -663,13 +663,18 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial) } // check all predefined types if (aiPTI_String == prop->mType) { - // FIX: strings are now stored in a less expensive way ... - if (prop->mDataLength < 5 || prop->mDataLength < 4 + *reinterpret_cast(prop->mData) + 1) { + // FIX: strings are now stored in a less expensive way, but we can't use the + // validation routine for 'normal' aiStrings + uint32_t len; + if (prop->mDataLength < 5 || prop->mDataLength < 4 + (len=*reinterpret_cast(prop->mData)) + 1) { ReportError("aiMaterial::mProperties[%i].mDataLength is " "too small to contain a string (%i, needed: %i)", i,prop->mDataLength,sizeof(aiString)); } - Validate((const aiString*)prop->mData); + if(prop->mData[prop->mDataLength-1]) { + ReportError("Missing null-terminator in string material property"); + } + // Validate((const aiString*)prop->mData); } else if (aiPTI_Float == prop->mType) { if (prop->mDataLength < sizeof(float)) {