Compare commits

...

2 Commits

Author SHA1 Message Date
Kim Kulling 243c1e15fe glFT: refactoring. 2020-08-17 19:46:15 +02:00
kimkulling 6cca078947 closes https://github.com/assimp/assimp/issues/3348: reproduce fuzzer issues. 2020-07-31 16:34:29 +02:00
10 changed files with 109 additions and 115 deletions

View File

@ -51,66 +51,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
#include <assimp/Exceptional.h>
#include <map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <stdexcept>
#ifndef RAPIDJSON_HAS_STDSTRING
#define RAPIDJSON_HAS_STDSTRING 1
#endif
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
#define RAPIDJSON_NOMEMBERITERATORCLASS
#endif
#include <rapidjson/rapidjson.h>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
#pragma GCC diagnostic pop
#endif
#ifdef ASSIMP_API
# include <memory>
# include <assimp/DefaultIOSystem.h>
# include <assimp/ByteSwapper.h>
#else
# include <memory>
# define AI_SWAP4(p)
# define ai_assert
#endif
#include "AssetLib/glTFCommon/glTFCommon.h"
#if _MSC_VER > 1500 || (defined __GNUC___)
# define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
# else
# define gltf_unordered_map map
#endif
namespace glTF {
#ifdef ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
# include <unordered_map>
# if _MSC_VER > 1600
# define gltf_unordered_map unordered_map
# else
# define gltf_unordered_map tr1::unordered_map
# endif
#endif
#include "AssetLib/glTF/glTFCommon.h"
namespace glTF
{
using glTFCommon::shared_ptr;
using glTFCommon::IOSystem;
using glTFCommon::IOStream;

View File

@ -62,37 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include <vector>
#ifndef RAPIDJSON_HAS_STDSTRING
#define RAPIDJSON_HAS_STDSTRING 1
#endif
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
#define RAPIDJSON_NOMEMBERITERATORCLASS
#endif
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <rapidjson/rapidjson.h>
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
#pragma GCC diagnostic pop
#endif
#ifdef ASSIMP_API
#include <assimp/ByteSwapper.h>
#include <assimp/DefaultIOSystem.h>
#include <memory>
#else
#include <memory>
#define AI_SWAP4(p)
#define ai_assert
#endif
#if _MSC_VER > 1500 || (defined __GNUC___)
#define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
#else
@ -112,9 +81,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#endif
#include <assimp/StringUtils.h>
#include "AssetLib/glTF/glTFCommon.h"
#include "AssetLib/glTFCommon/glTFCommon.h"
namespace glTF2 {

View File

@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#include "AssetLib/glTF/glTFCommon.h"
#include "AssetLib/glTFCommon/glTFCommon.h"
#include <assimp/StringUtils.h>
#include <assimp/DefaultLogger.hpp>

View File

@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#include "AssetLib/glTF/glTFCommon.h"
#include "AssetLib/glTFCommon/glTFCommon.h"
namespace glTFCommon {

View File

@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
#include <assimp/Exceptional.h>
#include <assimp/StringUtils.h>
#include <algorithm>
#include <list>
@ -51,36 +52,49 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdexcept>
#include <string>
#include <vector>
#include <set>
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#define RAPIDJSON_HAS_STDSTRING 1
#define RAPIDJSON_NOMEMBERITERATORCLASS
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <rapidjson/rapidjson.h>
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
# pragma GCC diagnostic pop
#endif
#ifdef ASSIMP_API
#include <assimp/ByteSwapper.h>
#include <assimp/DefaultIOSystem.h>
#include <memory>
# include <assimp/ByteSwapper.h>
# include <assimp/DefaultIOSystem.h>
# include <memory>
#else
#include <memory>
#define AI_SWAP4(p)
#define ai_assert
# include <memory>
# define AI_SWAP4(p)
# define ai_assert
#endif
#if _MSC_VER > 1500 || (defined __GNUC___)
#define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
# define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
#else
#define gltf_unordered_map map
# define gltf_unordered_map map
#endif
#ifdef ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
#include <unordered_map>
#if _MSC_VER > 1600
#define gltf_unordered_map unordered_map
#else
#define gltf_unordered_map tr1::unordered_map
#endif
# include <unordered_map>
# if _MSC_VER > 1600
# define gltf_unordered_map unordered_map
# else
# define gltf_unordered_map tr1::unordered_map
# define gltf_unordered_set set
# endif
#endif
namespace glTFCommon {

View File

@ -818,8 +818,8 @@ ADD_ASSIMP_IMPORTER( X3D
)
ADD_ASSIMP_IMPORTER( GLTF
AssetLib/glTF/glTFCommon.h
AssetLib/glTF/glTFCommon.cpp
AssetLib/glTFCommon/glTFCommon.h
AssetLib/glTFCommon/glTFCommon.cpp
AssetLib/glTF/glTFAsset.h
AssetLib/glTF/glTFAsset.inl
AssetLib/glTF/glTFAssetWriter.h

View File

@ -2,8 +2,7 @@
# ----------------------------------------------------------------------
#
# Copyright (c) 2006-2020, assimp team
#
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms,
@ -189,8 +188,13 @@ SET( POST_PROCESSES
unit/utGenBoundingBoxesProcess.cpp
)
SET( FUZZER
unit/Fuzzer/utFuzzerTestCases.cpp
)
SOURCE_GROUP( UnitTests\\Compiler FILES unit/CCompilerTest.c )
SOURCE_GROUP( UnitTests\\Common FILES ${COMMON} )
SOURCE_GROUP( UnitTests\\Fuzzer FILES ${FUZZER} )
SOURCE_GROUP( UnitTests\\ImportExport FILES ${IMPORTERS} )
SOURCE_GROUP( UnitTests\\Material FILES ${MATERIAL} )
SOURCE_GROUP( UnitTests\\Math FILES ${MATH} )
@ -202,6 +206,7 @@ add_executable( unit
unit/Main.cpp
../code/Common/Version.cpp
${COMMON}
${FUZZER}
${IMPORTERS}
${MATERIAL}
${MATH}

View File

@ -0,0 +1,67 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/cimport.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
class utFuzzerTestCases : public ::testing::Test {
// empty
};
wchar_t *data = L"vn xx<78> > <20><><EFBFBD><EFBFBD><10><11><>";
TEST_F(utFuzzerTestCases, testFuzzerData) {
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT, NULL);
aiAttachLogStream(&stream);
Importer importer;
const aiScene *sc = importer.ReadFileFromMemory(data, 19 * sizeof(wchar_t),
aiProcessPreset_TargetRealtime_Quality, nullptr);
aiDetachLogStream(&stream);
EXPECT_EQ(nullptr, sc);
}

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,