mirror of
https://github.com/taglib/taglib.git
synced 2026-04-05 21:52:43 -04:00
Merge branch 'master' into merge-master-to-taglib2
Conflicts: ConfigureChecks.cmake config.h.cmake taglib/CMakeLists.txt taglib/ape/apeproperties.cpp taglib/fileref.cpp taglib/mp4/mp4atom.cpp taglib/mpc/mpcproperties.cpp taglib/mpeg/id3v2/frames/chapterframe.cpp taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp taglib/mpeg/id3v2/id3v2frame.cpp taglib/mpeg/id3v2/id3v2framefactory.cpp taglib/mpeg/id3v2/id3v2tag.cpp taglib/mpeg/mpegfile.cpp taglib/mpeg/mpegfile.h taglib/riff/aiff/aifffile.cpp taglib/riff/aiff/aiffproperties.cpp taglib/riff/aiff/aiffproperties.h taglib/riff/wav/infotag.cpp taglib/riff/wav/wavfile.cpp taglib/riff/wav/wavproperties.cpp taglib/toolkit/tdebug.cpp taglib/toolkit/tstring.cpp taglib/toolkit/tutils.h tests/test_aiff.cpp tests/test_id3v2.cpp tests/test_wav.cpp
This commit is contained in:
Binary file not shown.
BIN
tests/data/duplicate_id3v2.mp3
Normal file
BIN
tests/data/duplicate_id3v2.mp3
Normal file
Binary file not shown.
BIN
tests/data/excessive_alloc.aif
Normal file
BIN
tests/data/excessive_alloc.aif
Normal file
Binary file not shown.
BIN
tests/data/excessive_alloc.mp3
Normal file
BIN
tests/data/excessive_alloc.mp3
Normal file
Binary file not shown.
BIN
tests/data/infloop.mpc
Normal file
BIN
tests/data/infloop.mpc
Normal file
Binary file not shown.
BIN
tests/data/infloop.wav
Normal file
BIN
tests/data/infloop.wav
Normal file
Binary file not shown.
BIN
tests/data/longloop.ape
Normal file
BIN
tests/data/longloop.ape
Normal file
Binary file not shown.
BIN
tests/data/segfault.aif
Normal file
BIN
tests/data/segfault.aif
Normal file
Binary file not shown.
BIN
tests/data/segfault.mpc
Normal file
BIN
tests/data/segfault.mpc
Normal file
Binary file not shown.
BIN
tests/data/segfault.oga
Normal file
BIN
tests/data/segfault.oga
Normal file
Binary file not shown.
BIN
tests/data/segfault.wav
Normal file
BIN
tests/data/segfault.wav
Normal file
Binary file not shown.
1
tests/data/segfault2.mpc
Normal file
1
tests/data/segfault2.mpc
Normal file
@ -0,0 +1 @@
|
||||
MPCKSH
|
||||
BIN
tests/data/zerodiv.ape
Normal file
BIN
tests/data/zerodiv.ape
Normal file
Binary file not shown.
BIN
tests/data/zerodiv.mpc
Normal file
BIN
tests/data/zerodiv.mpc
Normal file
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <aifffile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
@ -13,32 +13,57 @@ class TestAIFF : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestAIFF);
|
||||
CPPUNIT_TEST(testReading);
|
||||
CPPUNIT_TEST(testSaveID3v2);
|
||||
CPPUNIT_TEST(testAiffCProperties);
|
||||
CPPUNIT_TEST(testFuzzedFile1);
|
||||
CPPUNIT_TEST(testFuzzedFile2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testReading()
|
||||
{
|
||||
ScopedFileCopy copy("empty", ".aiff");
|
||||
string filename = copy.fileName();
|
||||
RIFF::AIFF::File f(TEST_FILE_PATH_C("empty.aiff"));
|
||||
CPPUNIT_ASSERT_EQUAL(705, f.audioProperties()->bitrate());
|
||||
}
|
||||
|
||||
RIFF::AIFF::File *f = new RIFF::AIFF::File(filename.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(705, f->audioProperties()->bitrate());
|
||||
CPPUNIT_ASSERT(!f->audioProperties()->isAiffC());
|
||||
delete f;
|
||||
void testSaveID3v2()
|
||||
{
|
||||
ScopedFileCopy copy("empty", ".aiff");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
RIFF::AIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f.hasID3v2Tag());
|
||||
f.tag()->setTitle(L"TitleXXX");
|
||||
f.save();
|
||||
}
|
||||
|
||||
{
|
||||
RIFF::AIFF::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"TitleXXX"), f.tag()->title());
|
||||
}
|
||||
}
|
||||
|
||||
void testAiffCProperties()
|
||||
{
|
||||
ScopedFileCopy copy("alaw", ".aifc");
|
||||
string filename = copy.fileName();
|
||||
RIFF::AIFF::File f(TEST_FILE_PATH_C("alaw.aifc"));
|
||||
CPPUNIT_ASSERT(f.audioProperties()->isAiffC());
|
||||
CPPUNIT_ASSERT(f.audioProperties()->compressionType() == "ALAW");
|
||||
CPPUNIT_ASSERT(f.audioProperties()->compressionName() == "SGI CCITT G.711 A-law");
|
||||
}
|
||||
|
||||
RIFF::AIFF::File *f = new RIFF::AIFF::File(filename.c_str());
|
||||
CPPUNIT_ASSERT(f->audioProperties()->isAiffC());
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("ALAW"), f->audioProperties()->compressionType());
|
||||
CPPUNIT_ASSERT_EQUAL(String("SGI CCITT G.711 A-law"), f->audioProperties()->compressionName());
|
||||
delete f;
|
||||
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());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <apefile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
@ -16,6 +16,8 @@ class TestAPE : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testProperties399);
|
||||
CPPUNIT_TEST(testProperties396);
|
||||
CPPUNIT_TEST(testProperties390);
|
||||
CPPUNIT_TEST(testFuzzedFile1);
|
||||
CPPUNIT_TEST(testFuzzedFile2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -47,6 +49,18 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
|
||||
}
|
||||
|
||||
void testFuzzedFile1()
|
||||
{
|
||||
APE::File f(TEST_FILE_PATH_C("longloop.ape"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
void testFuzzedFile2()
|
||||
{
|
||||
APE::File f(TEST_FILE_PATH_C("zerodiv.ape"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestAPE);
|
||||
|
||||
@ -93,6 +93,7 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testRenderChapterFrame);
|
||||
CPPUNIT_TEST(testParseTableOfContentsFrame);
|
||||
CPPUNIT_TEST(testRenderTableOfContentsFrame);
|
||||
CPPUNIT_TEST(testShrinkPadding);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -201,7 +202,7 @@ public:
|
||||
"JPG"
|
||||
"\x01"
|
||||
"d\x00"
|
||||
"\x00", 18);
|
||||
"\x00", 14);
|
||||
ID3v2::Header header;
|
||||
header.setMajorVersion(2);
|
||||
ID3v2::AttachedPictureFrame *frame =
|
||||
@ -224,7 +225,7 @@ public:
|
||||
"JPG"
|
||||
"\x01"
|
||||
"d\x00"
|
||||
"\x00", 18);
|
||||
"\x00", 14);
|
||||
ID3v2::Header header;
|
||||
header.setMajorVersion(2);
|
||||
ID3v2::AttachedPictureFrame *frame =
|
||||
@ -1016,6 +1017,39 @@ public:
|
||||
f.render());
|
||||
}
|
||||
|
||||
void testShrinkPadding()
|
||||
{
|
||||
ScopedFileCopy copy("xing", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
MPEG::File f(newname.c_str());
|
||||
ID3v2::Tag *tag = f.ID3v2Tag(true);
|
||||
|
||||
ID3v2::TextIdentificationFrame *frame1 = new ID3v2::TextIdentificationFrame("TIT2");
|
||||
frame1->setText("Title");
|
||||
tag->addFrame(frame1);
|
||||
|
||||
ID3v2::AttachedPictureFrame *frame2 = new ID3v2::AttachedPictureFrame();
|
||||
frame2->setPicture(ByteVector(100 * 1024, '\xff'));
|
||||
tag->addFrame(frame2);
|
||||
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.length() > 100 * 1024);
|
||||
}
|
||||
|
||||
{
|
||||
MPEG::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT_EQUAL(true, f.hasID3v2Tag());
|
||||
|
||||
ID3v2::Tag *tag = f.ID3v2Tag();
|
||||
tag->removeFrames("APIC");
|
||||
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.length() < 10 * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);
|
||||
|
||||
@ -155,7 +155,7 @@ public:
|
||||
|
||||
MP4::Atoms *atoms = new MP4::Atoms(f);
|
||||
MP4::Atom *moov = atoms->atoms[0];
|
||||
CPPUNIT_ASSERT_EQUAL(long(77), moov->length);
|
||||
CPPUNIT_ASSERT_EQUAL(offset_t(77), moov->length);
|
||||
|
||||
f->tag()->itemListMap()["pgap"] = true;
|
||||
f->save();
|
||||
@ -169,7 +169,7 @@ public:
|
||||
atoms = new MP4::Atoms(f);
|
||||
moov = atoms->atoms[0];
|
||||
// original size + 'pgap' size + padding
|
||||
CPPUNIT_ASSERT_EQUAL(long(77 + 25 + 974), moov->length);
|
||||
CPPUNIT_ASSERT_EQUAL(offset_t(77 + 25 + 974), moov->length);
|
||||
delete atoms;
|
||||
delete f;
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <mpcfile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
@ -17,6 +17,10 @@ class TestMPC : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testPropertiesSV7);
|
||||
CPPUNIT_TEST(testPropertiesSV5);
|
||||
CPPUNIT_TEST(testPropertiesSV4);
|
||||
CPPUNIT_TEST(testFuzzedFile1);
|
||||
CPPUNIT_TEST(testFuzzedFile2);
|
||||
CPPUNIT_TEST(testFuzzedFile3);
|
||||
CPPUNIT_TEST(testFuzzedFile4);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -61,6 +65,30 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
|
||||
}
|
||||
|
||||
void testFuzzedFile1()
|
||||
{
|
||||
MPC::File f(TEST_FILE_PATH_C("zerodiv.mpc"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
void testFuzzedFile2()
|
||||
{
|
||||
MPC::File f(TEST_FILE_PATH_C("infloop.mpc"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
void testFuzzedFile3()
|
||||
{
|
||||
MPC::File f(TEST_FILE_PATH_C("segfault.mpc"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
void testFuzzedFile4()
|
||||
{
|
||||
MPC::File f(TEST_FILE_PATH_C("segfault2.mpc"));
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPC);
|
||||
|
||||
@ -16,6 +16,8 @@ class TestMPEG : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSaveID3v24);
|
||||
CPPUNIT_TEST(testSaveID3v24WrongParam);
|
||||
CPPUNIT_TEST(testSaveID3v23);
|
||||
CPPUNIT_TEST(testDuplicateID3v2);
|
||||
CPPUNIT_TEST(testFuzzedFile);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -92,6 +94,25 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void testDuplicateID3v2()
|
||||
{
|
||||
ScopedFileCopy copy("duplicate_id3v2", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
|
||||
// duplicate_id3v2.mp3 has duplicate ID3v2 tags.
|
||||
// Sample rate will be 32000 if can't skip the second tag.
|
||||
|
||||
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);
|
||||
|
||||
@ -15,6 +15,7 @@ class TestOggFLAC : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestOggFLAC);
|
||||
CPPUNIT_TEST(testFramingBit);
|
||||
CPPUNIT_TEST(testFuzzedFile);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -39,6 +40,12 @@ public:
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testFuzzedFile()
|
||||
{
|
||||
Ogg::FLAC::File f(TEST_FILE_PATH_C("segfault.oga"));
|
||||
CPPUNIT_ASSERT(!f.isValid());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestOggFLAC);
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <tag.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <infotag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <wavfile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
@ -14,8 +16,12 @@ class TestWAV : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE(TestWAV);
|
||||
CPPUNIT_TEST(testLength);
|
||||
CPPUNIT_TEST(testZeroSizeDataChunk);
|
||||
CPPUNIT_TEST(testID3v2Tag);
|
||||
CPPUNIT_TEST(testInfoTag);
|
||||
CPPUNIT_TEST(testStripTags);
|
||||
CPPUNIT_TEST(testFormat);
|
||||
CPPUNIT_TEST(testFuzzedFile1);
|
||||
CPPUNIT_TEST(testFuzzedFile2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -23,14 +29,80 @@ public:
|
||||
void testLength()
|
||||
{
|
||||
RIFF::WAV::File f(TEST_FILE_PATH_C("empty.wav"));
|
||||
CPPUNIT_ASSERT_EQUAL(true, f.isValid());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
|
||||
}
|
||||
|
||||
void testZeroSizeDataChunk()
|
||||
{
|
||||
RIFF::WAV::File f(TEST_FILE_PATH_C("zero-size-chunk.wav"));
|
||||
CPPUNIT_ASSERT_EQUAL(false, f.isValid());
|
||||
CPPUNIT_ASSERT(!f.isValid());
|
||||
}
|
||||
|
||||
void testID3v2Tag()
|
||||
{
|
||||
ScopedFileCopy copy("empty", ".wav");
|
||||
string filename = copy.fileName();
|
||||
|
||||
{
|
||||
RIFF::WAV::File f(filename.c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
|
||||
f.ID3v2Tag()->setTitle(L"Title");
|
||||
f.ID3v2Tag()->setArtist(L"Artist");
|
||||
f.save();
|
||||
}
|
||||
|
||||
{
|
||||
RIFF::WAV::File f(filename.c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"Title"), f.ID3v2Tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"Artist"), f.ID3v2Tag()->artist());
|
||||
|
||||
f.ID3v2Tag()->setTitle(L"");
|
||||
f.ID3v2Tag()->setArtist(L"");
|
||||
f.save();
|
||||
}
|
||||
|
||||
{
|
||||
RIFF::WAV::File f(filename.c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L""), f.ID3v2Tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L""), f.ID3v2Tag()->artist());
|
||||
}
|
||||
}
|
||||
|
||||
void testInfoTag()
|
||||
{
|
||||
ScopedFileCopy copy("empty", ".wav");
|
||||
string filename = copy.fileName();
|
||||
|
||||
{
|
||||
RIFF::WAV::File f(filename.c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
|
||||
f.InfoTag()->setTitle(L"Title");
|
||||
f.InfoTag()->setArtist(L"Artist");
|
||||
f.save();
|
||||
}
|
||||
|
||||
{
|
||||
RIFF::WAV::File f(filename.c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"Title"), f.InfoTag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L"Artist"), f.InfoTag()->artist());
|
||||
|
||||
f.InfoTag()->setTitle(L"");
|
||||
f.InfoTag()->setArtist(L"");
|
||||
f.save();
|
||||
}
|
||||
|
||||
{
|
||||
RIFF::WAV::File f(filename.c_str());
|
||||
CPPUNIT_ASSERT(f.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L""), f.InfoTag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(String(L""), f.InfoTag()->artist());
|
||||
}
|
||||
}
|
||||
|
||||
void testStripTags()
|
||||
@ -80,6 +152,19 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(true, f2.isValid());
|
||||
CPPUNIT_ASSERT_EQUAL((uint)6, f2.audioProperties()->format());
|
||||
}
|
||||
|
||||
void testFuzzedFile1()
|
||||
{
|
||||
RIFF::WAV::File f1(TEST_FILE_PATH_C("infloop.wav"));
|
||||
CPPUNIT_ASSERT(!f1.isValid());
|
||||
}
|
||||
|
||||
void testFuzzedFile2()
|
||||
{
|
||||
RIFF::WAV::File f2(TEST_FILE_PATH_C("segfault.wav"));
|
||||
CPPUNIT_ASSERT(f2.isValid());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestWAV);
|
||||
|
||||
Reference in New Issue
Block a user