diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index bb251d18..5dc84971 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -32,6 +32,7 @@ #endif #include +#include #include #include @@ -255,7 +256,7 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const !d->header->encryption()) { z_stream stream; - memset(&stream, 0, sizeof(z_stream)); + ::memset(&stream, 0, sizeof(z_stream)); if(inflateInit(&stream) != Z_OK) return ByteVector(); diff --git a/tests/data/excessive_alloc.aif b/tests/data/excessive_alloc.aif new file mode 100644 index 00000000..9cb3a6e1 Binary files /dev/null and b/tests/data/excessive_alloc.aif differ diff --git a/tests/data/excessive_alloc.mp3 b/tests/data/excessive_alloc.mp3 new file mode 100644 index 00000000..cd8aa2ab Binary files /dev/null and b/tests/data/excessive_alloc.mp3 differ diff --git a/tests/test_aiff.cpp b/tests/test_aiff.cpp index a99b2350..495049b2 100644 --- a/tests/test_aiff.cpp +++ b/tests/test_aiff.cpp @@ -1,9 +1,9 @@ -#include #include #include #include #include #include +#include #include "utils.h" using namespace std; @@ -14,7 +14,8 @@ class TestAIFF : public CppUnit::TestFixture CPPUNIT_TEST_SUITE(TestAIFF); CPPUNIT_TEST(testReading); CPPUNIT_TEST(testAiffCProperties); - CPPUNIT_TEST(testReading); + CPPUNIT_TEST(testFuzzedFile1); + CPPUNIT_TEST(testFuzzedFile2); CPPUNIT_TEST_SUITE_END(); public: @@ -33,12 +34,18 @@ public: CPPUNIT_ASSERT(f.audioProperties()->compressionName() == "SGI CCITT G.711 A-law"); } - void testFuzzedFiles() + void testFuzzedFile1() { RIFF::AIFF::File f(TEST_FILE_PATH_C("segfault.aif")); CPPUNIT_ASSERT(!f.isValid()); } + void testFuzzedFile2() + { + RIFF::AIFF::File f(TEST_FILE_PATH_C("excessive_alloc.aif")); + CPPUNIT_ASSERT(!f.isValid()); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestAIFF); diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp index 024da6a0..07b970ee 100644 --- a/tests/test_mpeg.cpp +++ b/tests/test_mpeg.cpp @@ -17,6 +17,7 @@ class TestMPEG : public CppUnit::TestFixture CPPUNIT_TEST(testSaveID3v24WrongParam); CPPUNIT_TEST(testSaveID3v23); CPPUNIT_TEST(testDuplicateID3v2); + CPPUNIT_TEST(testFuzzedFile); CPPUNIT_TEST_SUITE_END(); public: @@ -106,6 +107,12 @@ public: CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate()); } + void testFuzzedFile() + { + MPEG::File f(TEST_FILE_PATH_C("excessive_alloc.mp3")); + CPPUNIT_ASSERT(f.isValid()); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);